CSS content
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The content
CSS property is used in combination with the ::before
and ::after
pseudo-elements to generate content in an element.
The following table summarizes the usages context and the version history of this property.
Default value: | normal |
---|---|
Applies to: | The ::before and ::after pseudo-elements |
Inherited: | No |
Animatable: | No. See animatable properties. |
Version: | CSS 2, 3 |
Syntax
The syntax of the property is given with:
The example below shows the content
property in action.
Example
Try this code »h1::before {
content: "Note: ";
display: inline;
}
Note: The display
CSS property controls whether the content generated using the content
property is placed in a block-box or inline box.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
normal |
It computes to none for the :before and :after pseudo-elements. This is default value. |
none |
The pseudo-element is not generated. |
counter |
This value sets the content as a counter. See the counter-reset and counter-increment property for more information. |
string | Inserts the specified string (text content). |
url(url) |
The value of url() designates an external resource (such as an image). If the resource or image can't be displayed, it is either ignored or some placeholder shows up. |
attr(attribute) |
This function inserts the value of specified attribute before or after the selected element(s). If the subject of the selector does not have the specified attribute, an empty string will be inserted. Note: The attribute names shouldn't be enclosed in quotes. |
open-quote |
Insert the opening quotation mark. These values are replaced by the appropriate string from the quotes property. |
close-quote |
Insert the closing quotation mark. These values are replaced by the appropriate string from the quotes property. |
no-open-quote |
Do not display the opening quotation mark, but increments (decrements) the level of nesting for quotes. |
no-close-quote |
Do not display the closing quotation mark, but increments (decrements) the level of nesting for quotes. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element content property. |
Browser Compatibility
The content
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Pseudo Elements.
Related properties: counter-reset
, counter-increment
.