Skip to content

Commit 2cf810c

Browse files
committed
[css-color-adjust-1] Add forced-colors mode, based on MSFT “high contrast” mode described in https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/HighContrast/explainer.md and discussion in #3807
1 parent a647cfd commit 2cf810c

File tree

1 file changed

+128
-3
lines changed

1 file changed

+128
-3
lines changed

css-color-adjust-1/Overview.bs

Lines changed: 128 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Preferred Color Schemes {#preferred}
4949
To enable pages to adapt to the user's preferred color scheme,
5050
user agents will match the '@media/prefers-color-scheme' media query
5151
to the user's preferred color scheme.
52-
See [[MEDIAQUERIES-5]].
52+
<!-- See [[MEDIAQUERIES-5]]. -->
5353

5454
Additionally, if the author has indicated that the page can support this color scheme
5555
(see 'color-scheme'),
@@ -75,8 +75,8 @@ Preferred Color Schemes {#preferred}
7575
more invasive changes might be applied;
7676
see [[#forced]].
7777

78-
Opting Out of a Preferred Color Scheme: the 'color-scheme' property {#color-scheme-prop}
79-
-------------------------------------------------------------------
78+
Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme-prop}
79+
-----------------------------------------------------------------
8080

8181
<pre class=propdef>
8282
Name: color-scheme
@@ -219,6 +219,92 @@ The "color-scheme" <{meta}> value {#color-scheme-meta}
219219
Forced Color Schemes: the 'forced-color-adjust' property {#forced}
220220
====================
221221

222+
<dfn>Forced colors mode</dfn> is an accessibility feature
223+
intended to increase the readability of text through color contrast.
224+
Individuals with limited vision
225+
often find it more comfortable to read content
226+
when there is a a particular type of contrast
227+
between foreground and background colors.
228+
229+
Operating systems can provide built-in color themes,
230+
such as Windows’ high contrast black-on-white
231+
and high-contrast white-on-black themes.
232+
Users can also customize their own themes,
233+
for example to provide low contrast or hue contrast.
234+
235+
In <a>forced colors mode</a>,
236+
the user agent enforces the user’s preferred color palette on the page,
237+
overriding the author’s chosen colors for specific properties,
238+
see [[#forced-colors-properties]].
239+
It may also enforce a “backplate” underneath text
240+
(similar to the way backgrounds are painted on the ''::selection'' pseudo-element)
241+
to ensure adequate contrast for readability.
242+
243+
To enable pages to adapt to <a>forced colors mode</a>
244+
user agents will match the '@media/forced-colors' media query
245+
<!-- (see [[MEDIAQUERIES-5]]) -->
246+
and must provide the required color palette
247+
through the CSS system colors
248+
(see [[CSS-COLOR-4]]).
249+
Additionally,
250+
if the UA determines (based on Lab lightness),
251+
that the canvas color
252+
is clearly either dark or light
253+
(for some reasonable UA delineation of “dark” or “light”),
254+
then it must match the appropriate value
255+
of the '@media/prefers-color-scheme' media query
256+
and express a corresponding user preference for 'color-scheme'.
257+
This will allow pages that support light/dark color schemes
258+
to automatically adjust to more closely match
259+
the forced color scheme.
260+
Note that medium-lightness forced backgrounds may yield
261+
a '@media/prefers-color-scheme' of ''prefers-color-scheme/no-preference''.
262+
263+
<!--THOUGHTS
264+
This advice (below) maybe makes sense for (prefers-contrast),
265+
but is it really applicable to forced-colors as well?
266+
If so, should forced-colors be instead a 'forced' value on 'prefers-contrast',
267+
so that a (prefers-contrast) query will catch all of these cases at once?
268+
269+
Authors are encouraged to simplify the contrast in their pages
270+
when '@media/forced-colors' is ''active'',
271+
reducing effects such as shadows, fades, blurs, filters, gradients,
272+
and image or pattern fills
273+
that add complexity to discerning shape outlin
274+
-->
275+
276+
Properties Affected by Forced Colors Mode {#forced-colors-properties}
277+
-----------------------------------------
278+
279+
When <a>forced colors mode</a> is active
280+
and 'forced-color-adjust' is ''forced-color-adjust/auto'' (see below),
281+
the following <a>user origin</a> declarations [[!CSS-CASCADE-4]]
282+
are applied to the element:
283+
284+
<pre>
285+
color: revert !important;
286+
background-color: revert !important;
287+
border-color: revert !important;
288+
outline-color: revert !important
289+
column-rule-color: revert !important;
290+
scrollbar-colors: revert !important;
291+
-webkit-tap-highlight-color: revert !important; /* ISSUE: This is not in a spec anywhere! */
292+
293+
box-shadow: none !important;
294+
text-shadow: none !important;
295+
</pre>
296+
297+
Additionally, on <em>on user input controls (except button-like controls) only</em>:
298+
<pre>
299+
background-image: none !important;
300+
</pre>
301+
302+
UA may further tweak these <a>forced colors mode</a> heuristics
303+
to provide better user experience.
304+
305+
Opting Out of a Forced Color Scheme: the 'forced-color-adjust' property {#forced-color-adjust-prop}
306+
-----------------------------------------------------------------
307+
222308
<pre class=propdef>
223309
Name: forced-color-adjust
224310
Value: auto | none
@@ -227,6 +313,30 @@ Forced Color Schemes: the 'forced-color-adjust' property {#forced}
227313
Inherited: yes
228314
</pre>
229315

316+
The 'forced-color-adjust' property
317+
allows authors to opt particular elements
318+
out of <a>forced colors mode</a>,
319+
restoring full control over the colors to CSS.
320+
Values have the following meanings:
321+
322+
<dl dfn-type=value dfn-for=forced-color-adjust>
323+
: <dfn>auto</dfn>
324+
:: The element’s colors are automatically adjusted by the UA
325+
in <a>forced colors mode</a>.
326+
327+
: <dfn>none</dfn>
328+
:: The element’s colors are not automatically adjusted by the UA
329+
in <a>forced colors mode</a>.
330+
331+
Advisement: Authors should only use this value
332+
when they are themselves adjusting the colors
333+
to support the user’s color and contrast needs
334+
and need to make changes to the UA’s default adjustments
335+
to provide a more appropriate user experience
336+
for those elements.
337+
</dl>
338+
339+
ISSUE: Should this property be merged with 'color-adjust' somehow?
230340

231341
Performance-based Color Schemes: the 'color-adjust' property {#perf}
232342
===============================
@@ -302,3 +412,18 @@ Performance-based Color Schemes: the 'color-adjust' property {#perf}
302412
would make the directions harder to read with a quick glance
303413
when distracted in a car.
304414
</dl>
415+
416+
Acknowledgements {#acknowledgements}
417+
================
418+
419+
This specification would not be possible
420+
without the development efforts
421+
of various color adjustment features
422+
at Apple, Google, and Microsoft
423+
as well as discussions about print adjustments on www-style.
424+
In particular, the CSS Working Group would like to thank:
425+
Alison Maher,
426+
François Remy,
427+
イアンフェッティ
428+
429+
ISSUE: List additional MSFT / Apple / Google people here.

0 commit comments

Comments
 (0)