Computer >> Computer tutorials >  >> Programming >> CSS

CSS :first-letter pseudo-element


Use this element to add special style to the first letter of the text in a selector. The following example demonstrates how to use the :first-letter element to add special effects to the first letter of elements in the document.

Example

<html>
   <head>
      <style>
         p:first-letter {
            font-size: 5em;
         }
         p.normal:first-letter {
            font-size: 10px;
         }
      </style>
   </head>
   <body>
      <p class="normal"> First character of this paragraph will be normal and will
         have font size 10 px;
      </p>
      <p>The first character of this paragraph will be 5em big as defined
         in the CSS rule above. Rest of the characters in this paragraph
         will remain normal. This example shows how to use :first-letter pseduo
         element to give effect to the first characters of any HTML element.
       </p>
   </body>
</html>