Pseudo-elements

suggest change

Pseudo-elements select a generated box or a portion of an element rather than an independent DOM element:

.external-link::after {
  content: " ↗";
}

li::marker {
  color: rebeccapurple;
}

input::placeholder {
  color: color-mix(in srgb, currentColor 55%, transparent);
}

::selection {
  color: Canvas;
  background: CanvasText;
}

Common pseudo-elements include ::before, ::after, ::first-letter, ::first-line, ::marker, ::placeholder, ::selection, and ::backdrop.

Use the double-colon syntax, which distinguishes pseudo-elements from pseudo-classes. The single-colon spellings of :before, :after, :first-letter, and :first-line remain supported for compatibility with older content.

Generated content should be decorative or supplementary. Content required to understand or operate the page belongs in HTML because pseudo-element content has inconsistent accessibility behavior and is not part of the DOM.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents