Skip to content

Commit 46fc43b

Browse files
codersjjestelle
andauthored
Clarify attr() URL limitations and add image-set() example (#41948)
* Add clarification on `attr()` usage with `<url>` type in CSS * Update files/en-us/web/css/reference/values/attr/index.md Co-authored-by: Estelle Weyl <[email protected]> --------- Co-authored-by: Estelle Weyl <[email protected]>
1 parent 0d53570 commit 46fc43b

File tree

1 file changed

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

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ span[data-icon] {
124124
}
125125
```
126126

127+
However, this restriction applies only to places that strictly require a `<url>` type.
128+
Some functions — such as {{CSSxRef("image/image-set","image-set()")}} — can accept a `<string>` value that is later interpreted as a URL, allowing `attr()` to work in those contexts, depending on browser support:
129+
130+
```css
131+
span[data-icon] {
132+
background: image-set(attr(data-icon));
133+
}
134+
```
135+
127136
Values that use `attr()` get marked as _`attr()`-tainted_. Using an `attr()`-tainted value as or in a `<url>` makes a declaration become ["invalid at computed value time" or IACVT for short](https://www.bram.us/2024/02/26/css-what-is-iacvt/).
128137

129138
### Backwards compatibility

0 commit comments

Comments
 (0)