CSS :beforeSelectors
Complete CSS Selector Reference Manual
Example
Insert content before each <p> element:
p:before
{
content:"Read this: ";
}
{
content:"Read this: ";
}
Try it Yourself »
Definitions and explanations.
The :before selector inserts content before the selected element.
Usagecontentattribute to specify the content to be inserted.
Browser Support
The numbers in the table indicate the first browser version that supports the property.
| Selectors | |||||
|---|---|---|---|---|---|
| ::before | 4.0 | 9.0 Partial from 8.0 |
3.5 | 3.1 | 7.0 Partial from 4.0 |
Note:For before to run in IE8, you must declare<!DOCTYPE> 。
Related Articles
CSS Tutorial:CSS Pseudo-elements
CSS Selector Reference Manual:CSS :after selector
More Examples
Example
The content and styles inserted before each <p>:
p:before
{
content:"Read this -";
background-color:yellow;
color:red;
font-weight:bold;
}
{
content:"Read this -";
background-color:yellow;
color:red;
font-weight:bold;
}
Try it Yourself »
Complete CSS Selector Reference Manualother extensions