-
Notifications
You must be signed in to change notification settings - Fork 719
[css-contain] What is the migration path for Container Queries? #6175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We've talked about wanting to be able to test for at-rule existence in @supports in the past (I can't find the issues for it right now), but it might very well make sense to just allow a trivial "does this at-keyword look like something you support?" test, like `@supports at-rule(@container) {...} |
Both of our solutions exclude the long list of browsers supporting |
True, but fixing it "better" now makes the next time this problem comes up less troublesome. ^_^ |
Right, I absolutely support the feature. I'm not sure it solves the immediate issue. :) That feature would be more powerful if it can also test support for the at-rule condition, like |
Just for reference, with the syntax I suggested in #2463 at-rules with descriptors and with nested rules would be covered for testing via Sebastian |
So a few syntax options that I've seen in the comments here or linked… /* possibly using a function like at-rule() or rule() */
@supports (@container) { … }
@supports (@container (width > 20em)) { … }
@supports (@container, width > 20em) { … } This would certainly be helpful for things like @SebastianZ your linked syntax also includes a style block, since it's mainly concerned with testing descriptors inside a rule. Not clear if that's meant to be required, or part of what you're suggesting here? |
The syntax is meant to take any kind of at-rule to let the UA do a simple syntax pass to check whether the at-rule is supported or not. So, in the simplest case you'd then have something like this: @supports (@container { * { color: wheat; } }) {
...
} |
There's a lot of power in that, but I think ideally the simplest case could be a bit more focused on the at-rule and its arguments. Maybe if blocks were allowed to be empty? @supports (@container {}) { ... }
@supports (@media (prefers-reduced-motion: reduce) {}) { ... } |
Actually, they are, so that is totally valid syntax. Sebastian |
+1 to @mirisuzanne's suggestion of:
This is definitely needed and useful for negation to apply styles when progressively enhancing container queries:
This is more resilient than |
The CSS Working Group just discussed The full IRC log of that discussion |
Feels a bit inconsistent not to require |
@lilles My understanding of the discussion was that we're leaning towards individual functions for each at-rule: @supports not media(width > 40em) { … }
@supports not container(min-width: 40em) { … } (Here's a codepen demo of how it might work for Container Queries) There was also mention of an @container (min-width: 40em) { … }
@else { /* condition is negative */ } And, while I like that idea, I don't think it does what we want here. I would expect |
Sorry, I wasn't there and posted before I saw the notes. Separate functions sgtm. |
So I think some of the concerns @mirisuzanne mentioned (of needing to support this condition way before CSS.supports("not foo()") That returns Now with that said, in terms of fixing this, yeah, the proposal was on the lines of: @supports at-rule( To test support for an specific at-rule. @frivoal raised the concern of it being a bit footgunny in cases we extend the syntax of the at rules, so I think this was the most controversial. Then there was: @supports container( And: @supports media( And these need specific definitions because |
Firefox's behavior is intended to be correct, but I note that @supports does not define what to do with an unknown value that's escaped to the top level (@media does: https://drafts.csswg.org/mediaqueries-5/#evaluating). That needs fixing.
If you don't implement that, fwiw, then it's not safe for authors to use the new at-rule() or container() or whatever functions, since they'll invalidate the entire rule in older versions. :/ |
I think that |
Hmm, we don't have the "unknown" concept. We just treat all future syntax as unsupported (link). I agree that the spec seems at least weird. Is there an objection of adopting the Firefox behavior here? Anyhow should probably be moved to a separate issue. |
My codepen test of a |
It's funny:
So I guess authors can use |
I think that's a fine caveat/hack for authors to ensure better backwards-compatibility, but it would also be good to get these lined up across browsers moving forward. For the sake of future conditions, it would be good for all of these to evaluate as true. So in my mind we'd be looking for two resolutions here:
|
The CSS Working Group just discussed The full IRC log of that discussion |
@tabatkins I think it's essential that When we do add new functions to
I don't see how option 1 provides any useful benefit? |
Yeah, my original intention was that they should be the same - they both use Kleene 3-value boolean logic, where "unknown" negates to "unknown", and if the whole thing evaluates to "unknown" it is treated as false. But I see the logic in treating an @supports unknown as just plain false, because the supports queries aren't nuanced choices from equally-likely options, like MQs are. If you don't understand a supports condition, it's likely you don't understand the feature it's testing support for either. (That can be wrong, but it's much more likely to be right than not.) So yeah, it's much more likely to give a correct result if it's just a plain false. So I agree, we should remove the "unknown" value from supports conditions, and just treat unknown things as false. |
The CSS Working Group just discussed
The full IRC log of that discussion |
This is in line with this recent change to Conditional-3: > Removed the “unknown” value in CSS feature queries’ boolean logic, > defining unrecognized syntaxes as “false” instead. > w3c/csswg-drafts#6175
This is in line with this recent change to Conditional-3: > Removed the “unknown” value in CSS feature queries’ boolean logic, > defining unrecognized syntaxes as “false” instead. > w3c/csswg-drafts#6175
This is in line with this recent change to Conditional-3: > Removed the “unknown” value in CSS feature queries’ boolean logic, > defining unrecognized syntaxes as “false” instead. > w3c/csswg-drafts#6175
This is in line with this recent change to Conditional-3: > Removed the “unknown” value in CSS feature queries’ boolean logic, > defining unrecognized syntaxes as “false” instead. > w3c/csswg-drafts#6175
Not sure why I marked this as not needing edits. The current status seems to be:
@lilles noted recently that we might want a way to test for |
This was less necessary for the initial draft of container queries, which can be tested by checking for support of the new properties/values, eg: @supports (container-type: inline-size) { ... } Since style queries don't involve any new properties, a more general solution is required. |
While at-rules provide their own test for positive support, there is currently no way to test for lack of at-rule support.
With the introduction of media-queries it became common practice to start with a reasonable fallback outside the query, and add progressive enhancement inside the query. That progressive approach also works with some container-queries (see Andy Bell's example), but it falls apart if an author wants to use media-queries as the fallback. Ideally, authors would be able to test for the lack of container-query support, and only apply media-queries when CQ is unsupported (see @eeeps codepen attempt).
If all browsers release 1D containment (or any other new property/value syntax) at the same time as container queries, Eric's approach should work:
It's not likely that any browser would release
@container
before releasinginline-size
containment, but it is possible a browser would release 1d containment first. If that is the only new syntax to test, it could result in some false negatives: browsers that support bothinline-size
&@media
, but not@container
, would miss out on the fallback media-queries. That's not ideal.I think the only way to ensure this migration path works smoothly is to include container-query-specific syntax that can be tested by
@supports
. Theinline-size
value might work for that, but only if browsers are careful to implement both features together.The text was updated successfully, but these errors were encountered: