-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Add plain vs range syntax section to container queries guide #44014
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -560,6 +560,15 @@ Note that [`!important`](/en-US/docs/Web/CSS/Reference/Values/important) is allo | |||||
|
|
||||||
| The global `revert` and `revert-layer` are invalid as values in a `<style-feature>` and cause the container style query to be false. | ||||||
|
|
||||||
| #### Plain (`:`) versus range (`=`) syntax | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider doing all as below. I see the point of comparing the two you have because they look similar and I guess doing = will be a gotcha. But in most cases you'll likely us this as an actual range - so > is far more likely.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, having read the guide now, I'd be tempted to call this range syntax, make it mostly about range syntax, and expand it out with some of the information in the guide. Specifically
Thoughts? |
||||||
|
|
||||||
| When a `<style-feature>` includes a value, you can write the comparison in two forms that look similar but behave differently: | ||||||
|
|
||||||
| - `style(--n: 3)` (plain) matches the property's _computed value_ against the right-hand side. For an unregistered custom property, the computed value is the value as authored, so `style(--n: 3)` is false when `--n` is `calc(6/2)`. Use this form for keyword-like values, such as `style(--stock: low)`. | ||||||
| - `style(--n = 3)` (range) parses both sides as a number, length, percentage, etc., and compares numerically. With the same `--n: calc(6/2)`, `style(--n = 3)` is true. The range syntax also supports `<`, `<=`, `>`, `>=`, three-value intervals such as `style(0 < --n < 10)`, and flexible operand ordering. | ||||||
|
|
||||||
| For the full rules and more examples, see [Plain versus range syntax in style queries](/en-US/docs/Web/CSS/Guides/Containment/Container_size_and_style_queries#plain_versus_range_syntax_in_style_queries) in the container style queries guide. | ||||||
|
|
||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pepelsbey @dletorey Can you guys co-ordinate. I just reviewed a section on this topic in #44003
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PS See my comments on th intro https://github.com/mdn/content/pull/44014/changes#r3206101519 Most of this is still valid. If you make it more about the range and less about the comparion of forms this should just work. |
||||||
| ### Scroll-state queries | ||||||
|
|
||||||
| See [Using container scroll-state queries](/en-US/docs/Web/CSS/Guides/Conditional_rules/Container_scroll-state_queries) for scroll-state query examples. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all great. I'd argue a little of it should go in the reference, but even if it did it should all stay here too.