CSS attr() Function
Example
The following example inserts content after each link:
a:after {
content: " (" attr(href) ")";
}
Try it Yourself »
Definition and usage
The attr() function returns the attribute value of the selected element.
Supported version: CSS2
Browser Support
The numbers in the table indicate the first browser version number that supports the function.
| Function | |||||
|---|---|---|---|---|---|
| attr() | 2.0 | 8.0 | 1.0 | 3.1 | 9.0 |
Note:IE8 requires a !DOCTYPE declaration to support the attr() function.
CSS Syntax
attr(attribute-name)
| Value | Description |
|---|---|
| attribute-name | Required. The attribute name of the HTML element. |
other extensions