Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS content property

CSS content property

Example

The following example adds the URL (href attribute) in parentheses after each link:

a

:after

{

content:

" ("

attr

(

href

) ")"

;

}

Try it »


Property definition and usage

The content property is used together 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 this property.

property
content 1.0 8.0 1.0 1.0 4.0

content syntax and property 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 content to an empty value. Try it »
normal In :before and :after pseudo-elements it is treated as none, that is, also an empty value. Try it »
counter Set a counter; the format can be counter(name) or counter(name,style). The generated content is the count of the smallest range with the specified name for that pseudo-element; the format is specified by style (default is 'decimal' - decimal numbers) Try it »
attr*(attribute)* Returns the element's attribute as a string. Try it »
string Sets 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 of the content Try it »
no-close-quote Removes the closing quote of the content Try it »
url(url) Sets the link address of some media (images, sounds, video, etc.) Try it »
inherit Specifies that the value of the 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