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

Pardon for my ignorance, but what is the reason the type of the resulting value of the `light-dark()` has to be determinable (and determined) beforehand?

tl;dr: seconding Lea's remark

> In general, from what I've observed, authors really struggle with anything typed in CSS, so the fewer such warts we can have, the better.

Is the typing here even beneficial? Speaking for myself, my smooth brain expects exactly the seemingly simplest interpretation, where doing e.g.

```CSS
font-weight: light-dark(whatever, bolder);
```

would boil down to clearly invalid

```CSS
font-weight: whatever;
```

and do nothing in the "light mode", and to completely legitimate

```CSS
font-weight: bolder;
```

in the "dark mode". Nothing less, nothing more. Determining validity of the function alone doesn't make any sense in this mental model, since the concept is just a *"blind" syntactic sugar "macro"*.

In other words, it's the *current* state that seems like something quite difficult to explain:

```CSS
/* OK, green in the light mode */
body {
 --x: tan;
 color: light-dark(green, var(--x)); 
}
```

vs

```CSS
/* ERROR, invalid in either mode */
body {
 /* no --x OR --x not being interpretable as a `color` */
 color: light-dark(green, var(--x)); 
}
```

While it's perhaps nice that the latter is broken immediately, even in the "light mode", so I have a chance to catch it earlier, I'm not sure this benefit is worth the complexity. As I indicated, it appears to be way more cognitively (and presumably even computationally?) demanding, compared to the "syntactic sugar-y macro" mental concept. At this point, I have next to no clue how I would explain why `light-dark()` even cares about types of its arguments and why it becomes entirely invalid the moment one of its arguments (even the "unused" one) loses its proper type. It feels like overly strict optimisation or unexpectedly eager validation from the outsider's viewpoint.

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


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

Received on Wednesday, 15 October 2025 17:35:49 UTC