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/1871818 bugzil.la/1871816 bugzil.la/1871817 bugzil.la/1871820 Vendor position : positive
- Firefox for Android ❌ See bugzil.la/435426 bugzil.la/1871819 bugzil.la/1448251 bugzil.la/1871818 bugzil.la/1871816 bugzil.la/1871817 bugzil.la/1871820 Vendor position : positive
- Safari ❌ See webkit.org/b/26609
- Safari on iOS ❌ See webkit.org/b/26609
Developer signals
- State of CSS 2025: usage/favorite_new_features question
- State of CSS 2025: usage/css_missing_features question
- State of CSS 2025: usage/css_interoperability_features question
- State of CSS 2025: reading_list/reading_list question
- State of CSS 2025: other_features/other_features_pain_points question
- State of CSS 2025: layout/layout_pain_points question
- State of CSS 2025: features/all_features question
- State of CSS 2025: colors/colors_pain_points question
Web Platform Tests (WPT)
View the latest WPT test results for this featureView as JSON | Edit this feature | Report an issue | Web-features entry: source, dist