CSS Pseudo-Element (Cont.)


The :first-letter Pseudo-Element
The first-letter pseudo-element is used to add special style to the first letter of the text in a selector:

     


The first-letter pseudo-element can only be used with block-level elements. The properties below apply to the first-letter pseudo-element:
  • font properties
  • color properties
  • background properties
  • margin properties
  • padding properties
  • border properties
  • text-decoration
  • vertical-align
  • text-transform
  • line-height
  • float
  • clear
Pseudo-Element and CSS Classes
Pseudo-elements can be combined with CSS classes. The example below will make the first letter of all paragraphs with class="article" red.

     



Demonstration
The following demonstration shows how the script of HTML and CSS is displayed on the Web: