-
Notifications
You must be signed in to change notification settings - Fork 642
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
[css-media-queries-5] add clarification on applied order for multiple preferences #4895
Comments
I'm not sure what you mean by that - can you clarify? |
@tabatkins there were some question by me:
|
There's no hierarchy; they're independent preferences that can be queried separately or together, as the page author desires. (And notably, there's nothing about a light or dark color scheme that implies a particular level of contrast; you can do high and low contrast variations of either.)
Not really right now, because dealing with either preference involves assigning to the same properties ( That said, Color 5 is working on a (still very early stages, don't look to its details as particularly informative of a final design yet) automatic contrast adjuster, where you can feed it two colors and a desired contrast ratio and it spits out one of the colors adjusted appropriately. This should, if we do it right, let you do a quick-and-dirty contrast adjuster automatically: set a |
That isn't what it does (although there has been discussion about adding that functionality). You feed it a color, a list of colors (and optionally a contrast ratio) and it returns the first color in the list that meets or exceeds that ratio. If no ratio is given, it returns the one in the list with the highest contrast. |
@tabatkins this is an answer- I am suggesting that it be added to the spec for clarification for anyone who is reading it. |
The problem is that I'm not sure how I could word it as a clarification; all MQs have always been independent, so the mental space y'all approached it from to be able to ask the question isn't familiar enough to me to write guidance in avoiding it. ^_^ |
+
= hierarchy, because to handle all combinations I need to setup my queries that way, e.g. color-scheme and then contrast and results in those matrices of query (+ selectors)
This seems like tackling the problem of spawning the matrices. Thanks for pointing out, will keep an eye on this one. |
Hm, not sure what you mean by that. You do need to combine/nest the queries to cover all the combinations, yes. But the order you do them in makes no difference. All of the following are identical: @media (prefers-color-scheme: dark) {
@media (prefers-contrast: high) {
:root { --fg: white; --bg: black; }
}
}
@media (prefers-contrast: high) {
@media (prefers-color-scheme: dark) {
:root { --fg: white; --bg: black; }
}
}
@media (prefers-color-scheme: dark) and (prefers-contrast: high) {
:root { --fg: white; --bg: black; }
} |
Yep, I treated this nesting as hierarchy - from the perspective of a creator. I have to first think about contrast then color or the other way around. I also don't know if there are more (accessibility enhancing) queries that would add to that stack as well. With that a 2x2 it will get into a 3x3 matrix or even more. I think this is also the guidance @MelSumner is relating to - on what's the "usage preference". |
The spec: https://drafts.csswg.org/mediaqueries-5
While reading through it, I was looking for some indication or guidance as to the order in which preferences should be applied. Even if there is to be no preference, explicitly stating as such will likely be useful to authors.
Example:
If a user has
prefer-contrast
andprefer-color-theme
with some setting, which should the browser apply first?The text was updated successfully, but these errors were encountered: