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

Thanks for the summary @SebastianZ . It would be helpful to also outline the arguments for and against each.

One thing to note: it has been repeatedly mentioned that there is no real difference between `light-dark-image(...)` and `light-dark(image, ...)`. Philosophically this may be the case, but until we get something like #12806, it means that one of them can dynamically switch e.g. via a variable value, while the other one cannot.

My preference would also be to return a different type based on the parameters. Enabling existing primitives to _just work_ is usually much better than introducing additional syntax. If we want to provide a way to *coerce* to a given type, that can be done as a separate function.
In terms of API design, [forcing users to duplicate intent is an antipattern](https://lea.verou.me/blog/2025/user-effort/#signal-to-noise), and it's unfortunate that there is plenty of precedent for this in the language.

One consideration is whether the case of having different types is significant (where allowed), e.g. 

```css
background: light-dark(white, linear-gradient(gray, black));
```

It does complicate things a fair bit if so, but it *is* a natural thing to write, in places where either type is allowed.
There is a workaround however:
```css
background: light-dark(white, transparent) light-dark(none, linear-gradient(gray, black));
```
…so we can punt that and revisit later.

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


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

Received on Tuesday, 21 October 2025 20:39:19 UTC