CSS content Property
Description
The content property is the mechanism used by CSS to create generated content that does not exist in the source DOM. It is most commonly used in conjunction with pseudo-elements (for example ::before and ::after) to inject extra textual or graphical material at render time. Because the content is created by the style layer rather than by the document tree, it behaves like presentation-only content: it can visually augment a page without changing the underlying HTML structure.
Although generated via CSS, the boxes that carry generated content participate in normal layout and can be controlled by other CSS rules applied to the pseudo-element. Their display and placement are subject to the same layout rules as regular elements, and you can influence sizing, flow, and stacking through the pseudo-element’s own properties — for example display controls the box type the generated content produces. The generated content can also be used together with counter mechanisms to render automatic numbering; these counters are managed by counter-related properties such as counter-reset and the corresponding incrementing properties.
Because generated content is not part of the document’s DOM, it has important accessibility and interactivity implications. Assistive technologies and scripting environments treat it differently across user agents: some screen readers may ignore it, and it cannot be targeted by document-level selection or form submission in the same way as real DOM text. Consequently, content that is essential for understanding or interacting with a page should live in the HTML itself rather than be supplied only via content.
Finally, generated content can be styled, transformed and animated like any other layer of presentation, which makes it useful for decorative effects, status indicators, and small UI affordances without extra markup. When using animations or transitions on the pseudo-element carrying generated content, you are combining that presentational layer with the page’s visual dynamics — for instance, effects driven by the element’s animation rules such as animation. Keep in mind the trade-off between convenience and semantics: for maintainable, accessible interfaces, reserve generated content for nonessential enhancements.
Definition
- Initial value
- normal
- Applies to
- ::before and ::after pseudo-elements
- Inherited
- No
- Computed value
- Specified value
- Animatable
- No
- JavaScript syntax
- object.style.content
Interactive Demo
Syntax
content: [ <uri> ',' ]* [ normal | none | inhibit | <content-list> ]
Values
- <string>
- <uri>
- <counter>
- open-quote
- close-quote
- no-open-quote
- no-close-quote
- attr
- inherit
Example
Browser Support
The following information will show you the current browser support for the CSS content property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
