Example
The following example inserts the value of the href attribute in parenthesis after each link:
a:after {
content: " (" attr(href) ")";
}
Try it Yourself »
Definition and Usage
The attr() function returns the value of an attribute of the selected elements.
The value can then be used in the style sheet.
Version: | CSS2 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
Function | |||||
---|---|---|---|---|---|
attr() | 2.0 | 8.0 | 1.0 | 3.1 | 9.0 |
Note: IE8 supports the attr() function only if a !DOCTYPE is specified.
CSS Syntax
attr(attribute-name)
Value | Description |
---|---|
attribute-name | Required. The name of the attribute of the HTML element(s) |
< CSS Functions Reference