attr()
The attr() CSS function, in the context of any property, returns the value of an attribute of an HTML element, with the option to return it as a specific type or unit. You can set a default value for missing or invalid attributes.
Status
Limited availability
MDN documentation
Specifications
Browser support (view on caniuse.com)
- Chrome ❌ See crbug.com/400981738 bugs.chromium.org/p/chromium/issues/detail?id=246571
- Chrome Android ❌
- Edge ❌
- Firefox ❌ See bugzil.la/435426 Vendor position : positive
- Firefox for Android ❌ Vendor position : positive
- Safari ❌ See webkit.org/b/26609
- Safari on iOS ❌ See webkit.org/b/26609
Interop
- Included in Interop 2026
Web Platform Tests (WPT)
View the latest WPT test results for this featureDeveloper votes
Do you need this feature?
Let us know by leaving a 👍 reaction on the feedback issue. Don't forget to also leave a comment explaining your specific use case.
View as JSON | Edit this feature | Report an issue | Web-features entry: source, dist