Slide 5.25: CSS pseudo-element (cont.)
Slide 5.27: CSS navigation bar
Home

CSS Pseudo-Element (Cont.)


Multiple Pseudo-Element
Several pseudo-element can also be combined. In the following example, the first letter of a paragraph will be red, in an xx-large font size. The rest of the first line will be blue, and in small-caps. The rest of the paragraph will be the default font size and color:

     


CSS—The :before and :after Pseudo-Element
The :before/:after pseudo-element can be used to insert some content before/after an element. The following example inserts an image before each <h1> element:

     


Pseudo-Element
The “CSS” column indicates in which CSS version the property is defined (CSS1 or CSS2).

Pseudo-element Purpose CSS
:first-letter Adds special style to the first letter of a text 1
:first-line Adds special style to the first line of a text 1
:before Inserts some content before an element 2
:after Inserts some content after an element 2


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