bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

CSS Pseudo-elements

Concept visual

CSS Pseudo-elements

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

CSS Pseudo-Elements

Formula

A CSS pseudo - element is a keyword that can be added to a selector, to style a specific part of an element.

Some common use for pseudo-elements:

Style the first letter or first line, of an element

Insert content before or after an element

Style the markers of list items

Style the user-selected portion of an element

Style the viewbox behind a dialog box

Syntax

Formula

Pseudo - elements are denoted by a double colon (::) followed by the pseudo - element name:
selector::pseudo-element-name {

CSS properties

}

Text Pseudo-elements

Formula

Text pseudo - elements style specific parts of text content:
::first - line
  • Style the first line of text

Formula

::first - letter
  • Style the first letter of text

Content Pseudo-elements

Formula

Content pseudo - elements insert or style generated content:

::before - Insert content before an element ::after - Insert content after an element ::marker - Style list item markers ::selection

Formula

- Style user - selected text

::backdrop - Style dialog backdrop

CSS Pseudo-elements Reference

Formula

For a complete list of all CSS Pseudo - elements, visit our
CSS Pseudo - elements Reference.

Previous

CSS Structural Pseudo-classes

Next

CSS Pseudo-elements for Text