Pseudo-elements
suggest changePseudo-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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents