diff --git a/files/en-us/web/css/reference/values/attr/index.md b/files/en-us/web/css/reference/values/attr/index.md index 847390622b18cb7..22040870482c4d2 100644 --- a/files/en-us/web/css/reference/values/attr/index.md +++ b/files/en-us/web/css/reference/values/attr/index.md @@ -56,6 +56,9 @@ attr(data-size type( | )) attr(data-count type(), 0) attr(data-width px, inherit) attr(data-something, "default") + +/* With namespace */ +attr(color|myAttr type(*), red) ``` ### Parameters @@ -70,6 +73,19 @@ The parameters are: - `` - : The attribute name whose value should be retrieved from the selected HTML element(s). + - Namespaces + - : The attribute name can contain a [`namespace`](/en-US/docs/Web/CSS/Guides/Namespaces) which allows the targeting elements of [XML](/en-US/docs/Web/XML)-based markup languages such as [SVG](/en-US/docs/Web/SVG) or [MathML](/en-US/docs/Web/MathML). + + ```css + @namespace svg url("http://www.w3.org/2000/svg"); + a { + fill: attr(svg|myattr type(*), green); + } + ``` + + > [!NOTE] + > If no namespace is specified (just an identifier is given, like `attr(foo)`), the null namespace is implied. This is usually what's desired, as namespaced attributes are rare. As with attribute selectors, the case-sensitivity of `` depends on the document language. + - `` - : Specifies how the attribute value is parsed into a CSS value. This can be the `raw-string` keyword, a {{cssxref("type()")}} function, or a CSS dimension unit (specified using an `` identifier). When omitted, it defaults to `raw-string`. - `raw-string`