CSS Pseudo-elements
A CSS pseudo-element is used to style specified parts of an element.
A CSS pseudo-element is used to style specified parts of an element.
For example, it can be used to:
- Style the first letter, or line, of an element
- Insert content before, or after, the content of an element
Syntax
The syntax of pseudo-elements:
selector::pseudo-element {
property: value;
}
The ::first-line Pseudo-element
The ::first-line pseudo-element is used to add a special style to the first line of a text.
Preview
The ::first-letter Pseudo-element
The ::first-letter pseudo-element is used to add a special style to the first letter of a text.
Preview
The ::before Pseudo-element
The ::before pseudo-element can be used to insert some content before the content of an element.
Preview