- A CSS
pseudo-elementis a keyword added to a selector that lets you style a specific part of the selected element(s) -
For example,
::first-linecan be used to change the font of the first line of a paragraph syntaxselector::pseudo-element { property: value; }-
Double colons (
::) are used forpseudo-elements -
This distinguishes
pseudo-elementsfrompseudo-classesthat use a single colon (:) in their notation -
Pseudo-elementsdo not exist independently -
The element of which a
pseudo-elementis a part is called its originating element -
A
pseudo-elementmust appear after all the other components in the complex or compound selector - The last element in the selector is the originating element of the pseudo-element
-
For example, you can select a paragraph's
first line using
p::first-linebut not the first-line's children -
So
p::first-line > *is invalid -
A
pseudo-elementcan be selected based on the current state of the originating element -
For example,
p:hover::first-lineselects the first line (pseudo-element) of a paragraph when the paragraph itself is being hovered (pseudo-class)