CSS content
Property
Example
The following example will add the URL (href attribute) in parentheses after each link:
a:after {
content: " (" attr(href) ")";
}
Property Definition and Usage
The content
property is used with the :before
and :after
pseudo-elements to insert generated content.
Default value: | normal |
---|---|
Inherited: | no |
--- | --- |
Version: | CSS2 |
--- | --- |
JavaScript syntax: | object.style.content="url(beep.wav)" |
--- | --- |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
content | 1.0 | 8.0 | 1.0 | 1.0 | 4.0 |
Content Syntax and Values
Syntax format:
content: normal|none|counter|attr|string|open-quote|close-quote|no-open-quote|no-close-quote|url|initial|inherit;
Value | Description | Example |
---|---|---|
none | Sets the content to be empty. | Try it » |
normal | Treated as none in :before and :after pseudo-elements, which means it is also empty. |
Try it » |
counter | Sets a counter, the format can be counter(name) or counter(name, style) . The generated content is the value of the counter at this pseudo-element; the format is specified by style (default is 'decimal' – decimal number). |
Try it » |
attr(attribute) | Returns the string value of the element's attribute. | Try it » |
string | Sets the text content. | Try it » |
open-quote | Sets the opening quote. | Try it » |
close-quote | Sets the closing quote. | Try it » |
no-open-quote | Removes the opening quote. | Try it » |
no-close-quote | Removes the closing quote. | Try it » |
url(url) | Sets a link to a media file (image, sound, video, etc.). | Try it » |
inherit | Specifies that the value of the content property should be inherited from the parent element. |