CSS Tutorial

The language for styling web pages.

CSS Pseudo-elements

CSS Pseudo-elements

A CSS pseudo-element is used to style specified parts of an element, like the first line/letter, or to insert content before/after the element.

Common Pseudo-elements:

  • ::before - Insert content before element
  • ::after - Insert content after element
  • ::first-line - Style first line of text
  • ::first-letter - Style first letter
  • ::selection - Style highlighted text
  • ::placeholder - Style input placeholder

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics