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:
selector::pseudo-element { property: value; }
::afterarrow-up-right
p::after
Insert something after the content of each <p> element
::beforearrow-up-right
div.redDiv::before
Insert something before the content of each <div class='redDiv'> element
<div class='redDiv'>
::first-letterarrow-up-right
.someClass::first-letter
someClass::first-letter
Selects the first letter of each element haing classsomeClass
someClass
::first-linearrow-up-right
p::first-line
Selects the first line of each <p> element
::markerarrow-up-right
::marker
Selects the markers of list items
::selectionarrow-up-right
p::selection
Selects the portion of an element that is selected by a user
Last updated 3 years ago