← Back to functions
CSS Function
attr()
ContentRetrieves the value of an HTML attribute and uses it in CSS.
Syntax
attr(attribute-name)
Example
content: attr(data-tooltip);
Common use cases
- Displaying tooltips from data-attributes
- Dynamic pseudo-element content
- Showing link URLs in print styles
Practical developer insight
attr() currently works reliably only with the content property — support for other properties like width is still experimental in most browsers.