CSS contentProperty
Example
The following example will add the URL (href attribute) in parentheses after each link:
a:after
{
content: " (" attr(href) ")";
}
Try it Yourself »
Attribute definition and usage instructions
The content property is used in conjunction with the :before and :after pseudo-elements to insert content.
| Default value: | normal |
|---|---|
| Inherited: | no |
| version: | CSS2 |
| JavaScript Syntax: | object.style.content="url(beep.wav)" |
Browser Support
The numbers in the table indicate the first browser version that supports the property.
| Property | |||||
|---|---|---|---|---|---|
| content | 1.0 | 8.0 | 1.0 | 1.0 | 4.0 |
content syntax and attribute values
Syntax:
content: normal|none|counter|attr|string|open-quote|close-quote|no-open-quote|no-close-quote|url|initial|inherit;
| Value | Description | Example |
|---|---|---|
| none | Set content to an empty value. | Try it Yourself » |
| normal | In the :before and :after pseudo-class elements, it is treated as none, which is also an empty value. | Try it Yourself » |
| counter | Set counter, format can becounter(name)orcounter(name,style)The generated content is a count of the smallest scope with the specified name for that pseudo-class element; the format is specified by style (default is 'decimal' — decimal numbers). | Try it Yourself » |
| attr(attribute) | Returns the element's attribute as a string. | Try it Yourself » |
| string | Set text content | Try it Yourself » |
| open-quote | Set opening quote. | Try it Yourself » |
| close-quote | Set closing quote. | Try it Yourself » |
| no-open-quote | Remove the opening quote of the content | Try it Yourself » |
| no-close-quote | Remove the closing quote of the content | Try it Yourself » |
| url(url) | Sets the link address for some kind of media (image, sound, video, etc.). | Try it Yourself » |
| inherit | The value of the specified content property should be inherited from the parent element. |
More Examples
CSS Select Option Small Triangle (Arrow) Style Code
Related Articles
CSS Reference Manual::before pseudo-element
CSS Reference Manual::after pseudo-element
other extensions