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 133 Released on 2025-02-04
- Chrome Android 133 Released on 2025-02-04
- Edge 133 Released on 2025-02-06
- Firefox ❌ See bugzil.la/435426 bugzil.la/1871819 bugzil.la/1448251 bugzil.la/1871815 bugzil.la/1871818 bugzil.la/1871816 bugzil.la/1871817 bugzil.la/1871820 bugzil.la/1448252 Vendor position : positive
- Firefox for Android ❌ See bugzil.la/435426 bugzil.la/1871819 bugzil.la/1448251 bugzil.la/1871815 bugzil.la/1871818 bugzil.la/1871816 bugzil.la/1871817 bugzil.la/1871820 bugzil.la/1448252 Vendor position : positive
- Safari ❌ See webkit.org/b/26609
- Safari on iOS ❌ See webkit.org/b/26609
Surveys
- State of CSS 2025 > usage > favorite new features
- State of CSS 2025 > usage > css missing features
- State of CSS 2025 > usage > css interoperability features
- State of CSS 2025 > reading list > reading list
- State of CSS 2025 > other features > other features pain points
- State of CSS 2025 > layout > layout pain points
- State of CSS 2025 > features > all features
- State of CSS 2025 > colors > colors pain points
Web Platform Tests (WPT)
View the latest WPT test results for this featureDeveloper signals
Votes: 54
If you want this feature to be available in all browsers, vote for it by adding a thumbs up reaction (👍) to this GitHub issue, and leave a comment with more information.
View as JSON | Edit this feature | Report an issue | Web-features entry: source, dist