Re: [csswg-drafts] [css-color-adjust-1][mediaqueries-5] Fold `forced-colors` and `prefers-contrast`? (#3856)

Something I thought about after the call:

The `prefers-contrast: forced` value reduces the information available to authors who want to customize content for forced colors mode, when browser styles won't be sufficient for that content (e.g., charts, syntax-highlighted code).

As the spec is currently defined, an author could identify that the browser is in forced colors mode, and then use a mix of the `prefers-contrast` and `prefers-color-scheme` to toggle between high-contrast, low-contrast, dark and light modes for that custom content, so that it best matches the forced-color scheme and the user's preference.  Sample code:

```css
/** pick a syntax scheme, these should cover all possible combinations **/
@import url(solarized-light.css) (prefers-contrast: low) AND (NOT (prefers-color-scheme: dark));
@import url(solarized-dark.css) (prefers-contrast: low) AND (prefers-color-scheme: dark);
@import url(high-contrast-light.css) (NOT (prefers-contrast: low)) AND (prefers-color-scheme: light);
@import url(high-contrast-dark.css) (NOT (prefers-contrast: low)) AND (NOT (prefers-color-scheme: light));

code.highlight {
  forced-color-adjust: none;
  /* always use the syntax highlighting colors for highlighted code */
}
```

With `prefers-contrast: forced`, there is no information about what the user prefers if the forced colors aren't sufficient.

One option would be to treat the query values as non-exclusive categories.  So both `prefers-contrast: forced` and `prefers-contrast: high` could match at the same time. But that just seems like an unnecessary duplication of the `forced-colors: active` query.

So maybe a better compromise would be to add a `prefers-contrast: other` value, instead of `forced`. This would be used if the user agent is in forced color mode, but the forced color mode cannot be clearly defined as either high or low contrast. It would still evaluate true for the Boolean query (if the author is really just interested in knowing if there is a user preference without caring what it is), but would not replace the useful information from `prefers-contrast: high` and `prefers-contrast: low`.

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

Received on Wednesday, 10 June 2020 19:22:55 UTC