Skip to content

Commit bb412ee

Browse files
dletoreygithub-actions[bot]pepelsbey
authored
added namespace to attr() (mdn#43788)
* added namespace to attr() * Update files/en-us/web/css/reference/values/attr/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update files/en-us/web/css/reference/values/attr/index.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update files/en-us/web/css/reference/values/attr/index.md Co-authored-by: Vadim Makeev <hi@pepelsbey.dev> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Vadim Makeev <hi@pepelsbey.dev>
1 parent e34c0b9 commit bb412ee

File tree

1 file changed

+16
-0
lines changed
  • files/en-us/web/css/reference/values/attr

1 file changed

+16
-0
lines changed

files/en-us/web/css/reference/values/attr/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ attr(data-size type(<length> | <percentage>))
5656
attr(data-count type(<number>), 0)
5757
attr(data-width px, inherit)
5858
attr(data-something, "default")
59+
60+
/* With namespace */
61+
attr(color|myAttr type(*), red)
5962
```
6063

6164
### Parameters
@@ -70,6 +73,19 @@ The parameters are:
7073

7174
- `<attr-name>`
7275
- : The attribute name whose value should be retrieved from the selected HTML element(s).
76+
- Namespaces
77+
- : 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).
78+
79+
```css
80+
@namespace svg url("http://www.w3.org/2000/svg");
81+
a {
82+
fill: attr(svg|myattr type(*), green);
83+
}
84+
```
85+
86+
> [!NOTE]
87+
> 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 `<attr-name>` depends on the document language.
88+
7389
- `<attr-type>`
7490
- : 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 `<attr-unit>` identifier). When omitted, it defaults to `raw-string`.
7591
- `raw-string`

0 commit comments

Comments
 (0)