Re: [csswg-drafts] [css-values-5] Using `if()` to do dark/light switching of image urls. (#10577)

I do think it would be useful to have as a container query. There are cases where you need to account for both internal contrast in an element, and also how the element contrasts with it's broader context. 

I also agree with @LeaVerou that there's a lot of overlap in the conditions we'll want across `@container` and `if()` – so we should clarify how they relate, and how to provide features that work across both. They are not equivalent in what target element they query – `if()` is a self-query, while `@container` is an ancestor-query – but I think any shared syntax should always have the same shape to get the same info from the target. I think that's true with `style()` and should continue to be the pattern for other functions that work in both places.

Which I think should include this one. I don't feel strongly that they _have to_ happen at the same time, but I do think we should answer that question about how to keep these two conditional features in sync sooner rather than later. And I might argue that the default should be for features to work in both, and we should need good evidence to support only one or the other.

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


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

Received on Thursday, 31 July 2025 03:24:34 UTC