::after creates a pseudo-element that acts as the last child of the selected element. It is inline by default and is usually paired with the content property for icons, labels, or decoration.
Accessibility Prefer real HTML for meaning
Generated ::after text is not reliably read by screen readers. Keep important information in the document, not only in CSS.
Notecontent is required to show
If content is omitted, invalid, normal, or none, the pseudo-element is not rendered.
Syntax
CSS Syntax
syntax.css
selector::after{ content: …; … }
Prefer double-colon ::after. The older single-colon :after still works in browsers.
Read the attribute.attr(href) copies the href value.
Wrap it in a string. Parentheses make the URL easy to scan.
Print use case. Handy for print stylesheets; keep a11y needs in mind on screen.
Edge Cases & Pitfalls
Most “::after is broken” bugs are missing content or a replaced element.
content
No content, no box
Omitting content, or using none / normal, hides the pseudo-element entirely.
replaced
Replaced elements ignore it
img, input, and similar replaced elements cannot host ::after. Style a wrapper instead.
a11y
Do not hide critical text in CSS
Required labels, errors, and instructions belong in HTML so assistive tech can read them.
stack
::after paints after ::before
With no z-index, ::after content sits above ::before because it comes later in the flow.
syntax
Prefer ::after over :after
Double colon marks a pseudo-element. Single colon still works for compatibility.
Compatibility
Browser Support
::after is a browser CSS pseudo-element. Node.js, Deno, and Bun do not evaluate it.
✓ Baseline · Widely available
::after
Supported in all major browsers for decades (Baseline Widely available). Safe for decorative UI patterns.
99%All modern browsers
Google ChromeAll
Full
Mozilla FirefoxAll
Full
Apple SafariAll
Full
Microsoft EdgeAll
Full
OperaAll
Full
Samsung InternetAll
Full
Internet Explorer8+
Full
selector::afterUniversally supported
Bottom line: Production-ready. Prefer ::after (double colon), always set content, and keep meaningful text in HTML.
Remember
Key Takeaways
Role: last-child pseudo-element for generated content after real text.
Must-have: set content or nothing appears.
vs ::before: after the content vs before it.
Tip: decoration only—keep meaning in HTML for accessibility.
One line:el::after { content: "…"; } draws content after the element’s real children.
Frequently Asked Questions
It creates a pseudo-element as the last child of the selected element. You style it with content and other properties to show text or decoration after the real content.
If content is missing, invalid, normal, or none, the ::after box is not rendered. Use a string, "", attr(), or similar so it can appear.
Prefer the double-colon ::after form for pseudo-elements. Browsers still accept the older single-colon :after from CSS2.
No. Replaced elements like img and input do not support ::before / ::after. Wrap them and style the wrapper instead.
Not reliably. Screen readers may skip generated content. Keep important meaning in real HTML text, not only in ::after.
No. It is a browser CSS pseudo-element, not a Node.js feature.