CSS attr() Function
- Previous Page CSS atan2() function
- Next Page CSS blur() function
- Go Up One Level CSS Function Reference Manual
Definition and Usage
CSS's attr()
The function returns the attribute value of the selected element.
Example
The following example inserts the value of the href attribute after each <a> element and encloses it in parentheses:
a:after { content: " (" attr(href) ")"; }
CSS Syntax
attr(attribute-name type fallback)
Value | Description |
---|---|
attribute-name | Required. The attribute name of the HTML element. |
type |
Optional. The type or unit of the attribute value. It can be one of the following:
|
fallback | Optional. A fallback value if the property is missing or contains an invalid value. |
Technical Details
Version: | CSS2 |
---|
Browser Support
The numbers in the table indicate the browser version that first fully supports this function.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
attr() | ||||
2 | 8 | 1 | 3.1 | 9 |
type Value | ||||
Not Supported | Not Supported | Not Supported | Not Supported | Not Supported |
fallback Value | ||||
Not Supported | Not Supported | 119 | Not Supported | Not Supported |
- Previous Page CSS atan2() function
- Next Page CSS blur() function
- Go Up One Level CSS Function Reference Manual