Skip to content

Commit f9f81bf

Browse files
committed
[mediaqueries-5] prefers-contrast: custom
See w3c#6036
1 parent 6ae4b98 commit f9f81bf

1 file changed

Lines changed: 39 additions & 20 deletions

File tree

mediaqueries-5/Overview.bs

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2666,6 +2666,27 @@ Detecting the desire for increased or decreased color contrast from elements on
26662666
<dd>
26672667
Indicates that user has notified the system that they
26682668
prefer an interface that has a higher level of contrast.
2669+
2670+
<dt><dfn>custom</dfn>
2671+
<dd>
2672+
Indicates that the user has indicated
2673+
wanting a specific set of colors to be used,
2674+
but the contrast implied by these particular colors
2675+
is such that neither ''more'' nor ''less'' match.
2676+
2677+
Note: This value will match for users of [=forced colors mode=]
2678+
who have picked a palette that is neither particularly high nor low
2679+
contrast.
2680+
See [[#forced-colors]].
2681+
2682+
<div class=example>
2683+
A user calling for
2684+
<span style="background: #B64000; color: #00FFFF;">cyan text over a rust background</span>
2685+
is not--
2686+
at least in terms of luminosity--
2687+
expressing a need for particularly high or low contrast,
2688+
but this is not a lack of a preference either.
2689+
</div>
26692690
</dl>
26702691

26712692
<div class=note>
@@ -2677,14 +2698,22 @@ Detecting the desire for increased or decreased color contrast from elements on
26772698
to apply high contrast styles is incorrect and user-hostile,
26782699
as it would also impose high contrast styles to people who have requested the exact opposite.
26792700

2680-
However, it is also common to reduce visual clutter
2701+
However, it is also common to reduce visual clutter and color complexity
26812702
in response to both high and low contrast preferences.
26822703
In that case, it is appropriate to use <code class=lang-css>@media (prefers-contrast) { … }</code>
26832704
without specifying ''prefers-contrast/more'' or ''prefers-contrast/less'',
26842705
to do things like replacing background images with plain colors,
26852706
turning off decorative gradients,
26862707
or replacing border images or box shadows with simple solid borders.
2687-
See also [[#forced-colors]].
2708+
As ''prefers-contrast: custom''--
2709+
like ''prefers-contrast: more'' or ''prefers-contrast: less''--
2710+
evaluates to true in a [=boolean context=],
2711+
such simplifications would also benefit users of [=forced colors mode=],
2712+
even when their colors of choice do not result
2713+
in a particularly high or low contrast.
2714+
This is desirable,
2715+
as the reduced palette enforced by [=forced colors mode=]
2716+
calls for some visual simplification of the page.
26882717
</div>
26892718

26902719
<div class=example>
@@ -2746,17 +2775,19 @@ Detecting Forced Colors Mode: the 'forced-colors' feature</h3>
27462775
or some other arrangement that is neither particularly low or high contrast.
27472776
</div>
27482777

2749-
Additionally, when the user agent can determine
2750-
whether the forced color palette chosen by the user
2751-
has a high or low contrast,
2752-
one of ''prefers-contrast: more'' or ''prefers-contrast: less'' must match
2753-
in addition to ''forced-colors: active''.
2778+
In addition to ''forced-colors: active'',
2779+
the user agent must also match
2780+
one of ''prefers-contrast: more''
2781+
or ''prefers-contrast: less''
2782+
if it can determine
2783+
that the forced color palette chosen by the user
2784+
has a particularly high or low contrast,
2785+
and must make ''prefers-contrast: custom'' match otherwise.
27542786

27552787
Similarly,
27562788
if the forced color palette chosen by the user
27572789
fits within one of the color schemes described by 'prefers-color-scheme',
27582790
the corresponding value must also match.
2759-
See [[css-color-adjust-1#forced]] for details.
27602791

27612792
<dt><dfn>none</dfn>
27622793
<dd>
@@ -2771,18 +2802,6 @@ Detecting Forced Colors Mode: the 'forced-colors' feature</h3>
27712802
using the ''forced-colors'' media feature to detect when it is appropriate to do so.
27722803
</div>
27732804

2774-
<div class=example>
2775-
The reduced palette enforced by [=forced colors mode=]
2776-
can call for some visual simplification of the page.
2777-
''@media (forced-colors) or (prefers-contrast) { … }''
2778-
could thus be a useful query to conditionally apply styles that reduce visual clutter,
2779-
catching all users of forced colors and all users with contrast preferences.
2780-
''@media (prefers-contrast) { … }'' would leave out forced-colors users
2781-
with a color scheme that is neither particularly high nor low contrast,
2782-
while ''@media (forced-colors) { … }'' would instead leave out users with contrast preferences
2783-
that do not come from usage of [=forced colors mode=].
2784-
</div>
2785-
27862805
<h3 id="prefers-color-scheme">
27872806
Detecting the desire for light or dark color schemes: the 'prefers-color-scheme' feature</h3>
27882807

0 commit comments

Comments
 (0)