[csswg-drafts] [css-values-5] Arbitrary substitution function definition is ambiguous (#13083)

nex3 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-5] Arbitrary substitution function definition is ambiguous ==
Currently, the definition of [arbitrary substitution functions](https://www.w3.org/TR/css-values-5/#arbitrary-substitution) says:

> If a property value contains one or more arbitrary substitution functions, and those functions are themselves syntactically valid, the entire value’s grammar must be assumed to be valid at parse time.

The conditional clause could be read one of two ways:

1. If there are **any** valid arbitrary substitution functions, ...
2. If there are any arbitrary substitution functions and **all of them** are valid, ...

This has implications for whether ASFs can be used to substitute in syntactically necessary elements of *other* ASFs. For example, one could write:

```css
:root {
  --comma: ,;
  background-color: var(--undefined var(--comma) red);
}
```

If the property is valid, then the spec could be read to mean that the valid ASF (`var(--comma)`) is substituted first, then the second one is parsed and substituted ("If there are still arbitrary substitution functions in value (due to substitution), repeat the previous step"). Neither Firefox nor Chrome do this today, but it's not an unrealistic reading of the spec (especially considering that substituting syntactic elements of non-ASF functions is supported).

---

In fact, there's ambiguity even exclusively with valid ASFs. For example:

```css
:root {
  --list: red, green, blue;
  background-color: random-item(--x, var(--list));
}
```

The spec as written isn't explicit about whether ASFs should be resolved outside-in or inside-out, but the behavior of this snippet will differ considerably based on which one of those is implemented.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13083 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 10 November 2025 22:07:46 UTC