Re: [csswg-drafts] [css-images-4] Add `light-dark-image()`, or generalize `light-dark()` for images too? (#12513)

Functions like `light-dark()` aren't "macro-like" - they're fully typed values, same as `1em`, `red`, or `rgb(...)` (specifically, they're a `<color>`). We reserve the "macro-like" behavior for the few functions that *must* act like that, like `var()`; otherwise, we want to know the types of values so we can correctly parse things immediately. (Note that `light-dark()` *can't be resolved* to one of its arguments at parse-time; we have to wait until we actually apply styles to the document, so we can know what the element's *used color scheme* is, as that can be affected by the 'color-scheme' property on it or an ancestor.)

Being a `<color>` vs being something else can definitely affect parsing - for example, when parsing the `background` shorthand, if the final value is a `light-dark()`, knowing that it's a `<color>` means it'll get expanded into the `background-color` longhand; if it was an image it would instead need to be the final value in the `background-image` longhand. If it could be *either*, we wouldn't know how to parse it! We'd have to make an arbitrary decision, or look into its arguments and guess.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12513#issuecomment-3417506939 using your GitHub account


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

Received on Friday, 17 October 2025 23:28:29 UTC