Pseudo-elements
Pseudo-elements match virtual elements that don’t exist explicitly in the document tree. Pseudo-elements can be dynamic, inasmuch as the virtual elements they represent can change, for example, when the width of the browser window is altered. They can also represent content that’s generated by CSS rules.
In CSS1 and CSS2, pseudo-elements start with a colon (:), just like pseudo-classes. In CSS3, pseudo-elements start with a double colon (::), which differentiates them from pseudo-classes.
CSS1 gave us :first-letter
and :first-line;
CSS2 gave us generated content and the :before
and :after
pseudo-elements; and CSS3 added ::selection.
In this Section
- :first-letter
represents the first character of the first line of text within an element - :first-line
represents the first formatted line of text - :before
specifies content to be inserted before another element - :after
specifies content to be inserted after another element - ::selection
represents a part of the document that’s been highlighted by the user
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.
