{
 "caniuse": [
  "css3-attr"
 ],
 "compat_features": [
  "css.types.attr.declaration-value",
  "css.types.attr.fallback",
  "css.types.attr.type_function",
  "css.types.attr.type_function.angle",
  "css.types.attr.type_function.color",
  "css.types.attr.type_function.custom-ident",
  "css.types.attr.type_function.ident",
  "css.types.attr.type_function.image",
  "css.types.attr.type_function.integer",
  "css.types.attr.type_function.length",
  "css.types.attr.type_function.length-percentage",
  "css.types.attr.type_function.number",
  "css.types.attr.type_function.percentage",
  "css.types.attr.type_function.resolution",
  "css.types.attr.type_function.string",
  "css.types.attr.type_function.time",
  "css.types.attr.type_function.transform-function",
  "css.types.attr.type_function.url"
 ],
 "description": "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.",
 "description_html": "The <code>attr()</code> 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.",
 "group": [
  "css"
 ],
 "kind": "feature",
 "name": "attr()",
 "spec": [
  "https://drafts.csswg.org/css-values-5/#attr-notation"
 ],
 "status": {
  "baseline": false,
  "by_compat_key": {
   "css.types.attr.declaration-value": {
    "baseline": "low",
    "baseline_low_date": "2025-03-31",
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "119",
     "firefox_android": "119",
     "safari": "18.4",
     "safari_ios": "18.4"
    }
   },
   "css.types.attr.fallback": {
    "baseline": "low",
    "baseline_low_date": "2025-03-31",
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "119",
     "firefox_android": "119",
     "safari": "18.4",
     "safari_ios": "18.4"
    }
   },
   "css.types.attr.type_function": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.angle": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.color": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.custom-ident": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.ident": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.image": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.integer": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.length": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.length-percentage": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.number": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.percentage": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.resolution": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.string": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.time": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.transform-function": {
    "baseline": false,
    "support": {
     "chrome": "133",
     "chrome_android": "133",
     "edge": "133",
     "firefox": "155",
     "firefox_android": "155"
    }
   },
   "css.types.attr.type_function.url": {
    "baseline": false,
    "support": {}
   }
  },
  "support": {
   "chrome": "133",
   "chrome_android": "133",
   "edge": "133",
   "firefox": "155",
   "firefox_android": "155"
  }
 },
 "id": "attr",
 "groups": [
  "css"
 ],
 "specs": [
  {
   "url": "https://drafts.csswg.org/css-values-5/#attr-notation",
   "seriesComposition": "delta",
   "shortname": "css-values-5",
   "series": {
    "shortname": "css-values",
    "currentSpecification": "css-values-4",
    "title": "CSS Values and Units",
    "shortTitle": "CSS Values",
    "releaseUrl": "https://www.w3.org/TR/css-values/",
    "nightlyUrl": "https://drafts.csswg.org/css-values/"
   },
   "seriesVersion": "5",
   "shortTitle": "CSS Values 5",
   "seriesPrevious": "css-values-4",
   "organization": "W3C",
   "groups": [
    {
     "name": "Cascading Style Sheets (CSS) Working Group",
     "url": "https://www.w3.org/groups/wg/css/"
    }
   ],
   "release": {
    "url": "https://www.w3.org/TR/css-values-5/",
    "status": "Working Draft",
    "filename": "Overview.html"
   },
   "nightly": {
    "url": "https://drafts.csswg.org/css-values-5/",
    "status": "Editor's Draft",
    "alternateUrls": [
     "https://w3c.github.io/csswg-drafts/css-values-5/"
    ],
    "repository": "https://github.com/w3c/csswg-drafts",
    "sourcePath": "css-values-5/Overview.bs",
    "filename": "index.html"
   },
   "title": "CSS Values and Units Module Level 5",
   "source": "w3c",
   "categories": [
    "browser"
   ],
   "standing": "good",
   "tests": {
    "repository": "https://github.com/web-platform-tests/wpt",
    "testPaths": [
     "css/css-values"
    ]
   },
   "fragment": "attr-notation"
  }
 ],
 "mdnUrls": [
  {
   "slug": "Web/CSS/Reference/Values/attr",
   "title": "`attr()` CSS function",
   "anchor": null,
   "url": "https://developer.mozilla.org/docs/Web/CSS/Reference/Values/attr"
  }
 ],
 "standardPositions": [
  {
   "vendor": "mozilla",
   "url": "https://github.com/mozilla/standards-positions/issues/885",
   "position": "positive",
   "concerns": []
  }
 ],
 "hasNegativeStandardPosition": false,
 "stateOfSurveys": [
  {
   "name": "State of CSS 2026",
   "url": "https://2026.stateofcss.com/en-US/usage/#css_interoperability_features",
   "question": "usage",
   "subQuestion": "css_interoperability_features",
   "path": "dataAPI.surveys.state_of_css.css2026.usage.css_interoperability_features.freeform.allEditions.1.buckets.6.entity"
  },
  {
   "name": "State of CSS 2026",
   "url": "https://2026.stateofcss.com/en-US/features/#reading_list",
   "question": "reading_list",
   "subQuestion": "reading_list",
   "path": "dataAPI.surveys.state_of_css.css2026.reading_list.reading_list.combined.allEditions.0.buckets.16.entity"
  },
  {
   "name": "State of CSS 2026",
   "url": "https://2026.stateofcss.com/en-US/other_features/#other_features_pain_points_features",
   "question": "other_features",
   "subQuestion": "other_features_pain_points_features",
   "path": "dataAPI.surveys.state_of_css.css2026.other_features.other_features_pain_points_features.freeform.allEditions.1.buckets.4.nestedBuckets.0.entity"
  },
  {
   "name": "State of CSS 2026",
   "url": "https://2026.stateofcss.com/en-US/other_features/#other_features_pain_points",
   "question": "other_features",
   "subQuestion": "other_features_pain_points",
   "path": "dataAPI.surveys.state_of_css.css2026.other_features.other_features_pain_points.freeform.allEditions.1.buckets.8.nestedBuckets.0.entity"
  },
  {
   "name": "State of CSS 2026",
   "url": "https://2026.stateofcss.com/en-US/_all_features/#all_features",
   "question": "_all_features",
   "subQuestion": "all_features",
   "path": "dataAPI.surveys.state_of_css.css2026._all_features.all_features.42.entity"
  },
  {
   "name": "State of CSS 2025",
   "url": "https://2025.stateofcss.com/en-US/features/#reading_list",
   "question": "reading_list",
   "subQuestion": "reading_list",
   "path": "dataAPI.surveys.state_of_css.css2025.reading_list.reading_list.combined.allEditions.1.buckets.17.entity"
  },
  {
   "name": "State of CSS 2025",
   "url": "https://2025.stateofcss.com/en-US/features/#all_features",
   "question": "features",
   "subQuestion": "all_features",
   "path": "dataAPI.surveys.state_of_css.css2025.features.all_features.59.entity"
  }
 ],
 "chromeUseCounters": {},
 "interop": [
  {
   "year": 2026,
   "label": "interop-2026-attr",
   "url": "https://wpt.fyi/interop-2026?feature=interop-2026-attr"
  }
 ],
 "wpt": {
  "url": "https://wpt.fyi/results?q=feature:attr"
 },
 "developerSignals": {
  "url": "https://github.com/web-platform-dx/developer-signals/issues/293",
  "votes": 113
 },
 "bugs": {
  "firefox": [
   "https://bugzil.la/435426"
  ],
  "chrome": [
   "https://crbug.com/400981738",
   "https://bugs.chromium.org/p/chromium/issues/detail?id=246571"
  ]
 },
 "useCases": [
  {
   "description": "Style images based on their focal point for better UX when images resize to fit different viewport widths. The CMS that calculates focal points outputs data- attributes, then site themes can decide if they want to write the needed styles in their stylesheets. CSS could look like this, defined once for all images site-wide:\n\n```css\n[data-w-focus-x] {\n  object-fit: cover;\n  object-position: attr(data-w-focus-x) attr(data-w-focus-y);\n}\n```",
   "url": "https://github.com/web-platform-dx/developer-signals/issues/293#issuecomment-3817053729"
  },
  {
   "description": "We're building a set of UI components that users can assemble into web pages. We want to dynamically assign an anchor name via prop, so that any element can be anchored to another.\n\n```html\n<MyAnchorTarget data-anchor-name=\"--my-anchor-name\" id=\"my-anchor-target-component\" />\n\n<MyToBeAnchored data-anchor-name=\"--my-anchor-name\" id=\"my-to-be-anchored-component\" />\n\n<style>\n  #my-anchor-target-component {\n    anchor-name: attr(data-anchor-name)\n  }\n  \n  #my-to-be-anchored-component {\n    position-anchor: attr(data-anchor-name);\n  }\n  </style>\n```",
   "url": "https://github.com/web-platform-dx/developer-signals/issues/293#issuecomment-3915950915"
  }
 ],
 "baselineLowDateAsObject": null,
 "baselineHighDateAsObject": null,
 "blockedOn": "Safari",
 "blockedSince": "September 2026",
 "monthsBlocked": 0
}