Widely availableSupported across all major browsers. Safe to use in production.

Overview

The content CSS property sets the content inside of an element or pseudo-element, replacing the current value. It's often used with the ::before and ::after pseudo-elements to generate cosmetic content.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1
18
1
close-quote
1
12
1
1
18
1
element replacement

Element replacement

28
79
63
9
28
9

The CSS data type is a special type of image that consists of a progressive transition between two or more colors.

26
12
113
7
26
7
no-close-quote
1
12
1
1
18
1
no-open-quote
1
12
1
1
18
1
none
1
12
1
1
18
1
none applies to elements
Experimental

`content: none` for elements

91
normal
1
12
1
1
18
1
open-quote
1
12
1
1
18
1

The url() CSS function is used to include a file. The parameter is an absolute URL, a relative URL, a blob URL, or a data URL. The url() function can be passed as a parameter of another CSS function, like the attr function. Depending on the property for which it is a value, the resource sought can be an image, font, or a stylesheet. The url() functional…

1
12
1
1
18
1
Other

The CSS data type represents a sequence of characters. Strings are used in numerous CSS properties, such as content, font-family, and quotes.

1
12
1
1
18
1
CSS type
unicode escaped characters

Unicode escaped characters (`\xx`)

1
12
1
1
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 2 item(s)
Limitation
  • This browser only partially implements this feature
Implementation note
  • `content: <gradient>` doesn't paint on ::before/::after pseudo elements. See bug 1832901.
Notes 1 item(s)
Experimental
  • Requires an experimental browser flag to be enabled

Syntax

CSS
.external-link::after {
  content: ' ↗';
}
.chapter::before {
  content: counter(chapter) '. ';
}

Live demo

iconadd with::after

iconadd demo. with CSS::after

PreviewFullscreen

counter- with::before

counter- demo. with CSS::before

PreviewFullscreen

Quotes. Add

CSS Quotes. Add demo.

PreviewFullscreen

Use cases

  • Using Content

    The content CSS property sets the content inside of an element or pseudo-element, replacing the current value. It's often used with the ::before and ::after pseudo-elements to generate cosmetic content.

Cautions

  • May not be supported in older browsers.

Accessibility

  • Make sure visual changes are conveyed appropriately to assistive technology.

Powered by web-features