Skip to content

Commit 5aa0b8b

Browse files
committed
[css-color-adjust-1][editorial] Reorganize color-scheme section. w3c#5897
1 parent cee577e commit 5aa0b8b

File tree

1 file changed

+91
-98
lines changed

1 file changed

+91
-98
lines changed

css-color-adjust-1/Overview.bs

Lines changed: 91 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ Introduction {#intro}
3030
related to controlling how/when colors are auto-adjusted
3131
by the user agent:
3232

33-
* The concept of [=color schemes=]
33+
* [=Color schemes=]
3434
and the 'color-scheme' property,
3535
which controls whether or not browser-provided parts of the page's UI
3636
respect the user's chosen [=color scheme=].
3737

38-
* The concept of [=forced colors mode=]
38+
* [=Forced colors mode=]
3939
and the 'forced-color-adjust' property,
4040
which controls whether or not [=forced colors mode=] is allowed to apply to a given element.
4141

@@ -66,31 +66,30 @@ Preferred Color Schemes {#preferred}
6666
=======================
6767

6868
Operating systems and user agents often give users
69-
the ability to choose their preferred <dfn>color schemes</dfn>
69+
the ability to choose their <dfn export>preferred color scheme</dfn>
7070
for user interface elements.
71-
These are typically reflected in the user agent's rendering
71+
This <dfn export>color scheme</dfn> is typically reflected in the user agent's rendering
7272
of its navigation interface as well as in-page interface elements
7373
such as form controls and scrollbars,
74-
and are expected to also be reflected
75-
in the values of the CSS system colors.
74+
and is expected to also be reflected
75+
in the values of the CSS [=system colors=].
7676

7777
A UA can also allow the user to indicate a preference
7878
for the [=color scheme=] of the pages they view,
7979
requesting that the author adapt the page to those color preferences.
80-
(It is not required to express a preference;
80+
(It is not required to express such a preference;
8181
users can have preferences for operating system interface colors
8282
that they do not want imposed on pages.)
8383

84-
The most common preferences
85-
are a choice of “Light” vs “Dark” (or “Day Mode” vs “Night Mode”) color schemes,
86-
rendering things as mostly light- or dark-colored backgrounds,
87-
and with dark- or light-colored foregrounds (text, icons).
88-
This module,
89-
together with <a href="https://www.w3.org/TR/mediaqueries-5/">Media Queries Level 5</a>,
90-
defines controls to enable [=color scheme=] negotiation
91-
for “Light” and “Dark” [=color schemes=] (and no preference).
84+
The most common [=color scheme=] preferences are:
9285

93-
Note: <strong>The “Light” and “Dark” color schemes
86+
* A <dfn export local-lt=light>light color scheme</dfn> ("day mode")
87+
consists of light background colors and dark foreground/text colors.
88+
* A <dfn export local-lt=dark>dark color scheme</dfn> ("night mode")
89+
consists of the opposite,
90+
with dark background colors and light foreground/text colors.
91+
92+
Advisement: <strong>The [=light=] and [=dark color schemes=]
9493
don't represent an exact color palette (such as black-and-white),
9594
but a range of possible palettes.
9695
To guarantee specific colors, authors must specify those colors themselves.</strong>
@@ -100,37 +99,19 @@ Preferred Color Schemes {#preferred}
10099
it might be necessary to set both foreground and background colors together
101100
to ensure legibility [[WCAG21]].
102101

103-
To enable pages to adapt to the user's preferred [=color scheme=],
102+
To enable pages to adapt to the user's [=preferred color scheme=],
104103
user agents will match the '@media/prefers-color-scheme' media query
105-
to the user's preferred [=color schemes=].
106-
See [[MEDIAQUERIES-5]].
107-
108-
Additionally, if the author has indicated that the page can support this [=color scheme=]
109-
(see 'color-scheme'),
110-
the user agent must match the following to the user's preferred [=color scheme=]:
111-
112-
* the color of the [=canvas=] surface
113-
<span class=issue>find what we name this in other specs</span>,
114-
the initial value of the '/color' property,
115-
and the [[css-color-4#css-system-colors|system colors]]
116-
* the default colors of scrollbars and other interaction UI
117-
* the default colors of form controls and other "specially-rendered" elements
118-
* the default colors of other browser-provided UI, such as "spellcheck" underlines
104+
to the user's [=preferred color scheme=].
105+
[[!MEDIAQUERIES-5]]
106+
Complementing this, the 'color-scheme' property defined here
107+
lets the author indicate appropriate [=color schemes=]
108+
for UA-provided UI and colors in the page.
119109

120110
User agents <em>may</em> support additional [=color schemes=],
121111
however CSS does not support negotiation of additional [=color schemes=]:
122112
user agents should pursue standardization of these schemes,
123113
so that '@media/prefers-color-scheme' and 'color-scheme' can reflect the additional values.
124114

125-
Note: Aside from the small list of adjustments given above,
126-
user agents generally do not further adjust a page
127-
to match the user's preferred [=color scheme=],
128-
because the chance of accidentally ruining a page is too high.
129-
However, when particular color choices are required by the user
130-
(for accessibility reasons, for example),
131-
more invasive changes might be applied;
132-
see [[#forced]].
133-
134115
Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme-prop}
135116
-----------------------------------------------------------------
136117

@@ -152,9 +133,10 @@ Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme
152133
which [=color schemes=] it is designed to be rendered with.
153134
These values are negotiated with the user's preferences,
154135
resulting in a <dfn export>used color scheme</dfn>
155-
that affects UI things such as
136+
that affects things such as
156137
the default colors of form controls and scrollbars
157-
as well as the used values of the CSS system colors.
138+
as well as the used values of the [[css-color-4#css-system-colors|CSS system colors]].
139+
(See [[#color-scheme-effect]].)
158140

159141
Note: Because many pages were authored before color scheme support existed,
160142
user agents cannot automatically adapt the colors used in elements under their control,
@@ -168,55 +150,64 @@ Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme
168150
Indicates that the element isn't aware of [=color schemes=] at all,
169151
and so the element should be rendered with the browser's default [=color scheme=].
170152

171-
: <dfn lt="light | dark">[ light | dark | <<custom-ident>> ]+</dfn>
153+
: <dfn>light</dfn>
172154
::
173-
Indicates that the element is okay with being rendered with any of the listed [=color schemes=].
174-
175-
If the user's preferred color scheme,
176-
as indicated by the 'prefers-color-scheme' media feature,
177-
is present among the listed [=color schemes=],
178-
and is supported by the user agent,
179-
that's the element's [=used color scheme=].
180-
181-
Otherwise,
182-
if the user agent supports at least one of the listed [=color schemes=],
183-
the [=used color scheme=] is
184-
the first supported [=color scheme=] in the list.
185-
186-
Otherwise,
187-
the [=used color scheme=] is the browser default.
188-
(Same as ''color-scheme/normal''.)
189-
190-
''light'' represents a “light” [=color scheme=],
191-
with light background colors and dark foreground colors.
192-
''dark'' represents the opposite,
193-
with dark background colors and light foreground colors.
194-
195-
Note: User agents are <strong>not required</strong>
196-
to support any particular [=color scheme=],
197-
so only using a single keyword,
198-
such as ''color-scheme: dark'',
199-
to indicate a required [=color scheme=]
200-
is still not guaranteed to have any effect on the rendering of the element.
155+
Indicates that the page can handle the element being rendered
156+
in a [=light color scheme=].
201157

158+
: <dfn>dark</dfn>
159+
::
160+
Indicates that the page can handle the element being rendered
161+
in a [=dark color scheme=].
162+
163+
: <dfn><<custom-ident>></dfn>
164+
::
202165
<<custom-ident>> values are meaningless,
203166
and exist only for future compatibility,
204167
so that future added color schemes do not invalidate the 'color-scheme' declaration
205168
in legacy user agents.
206169
User agents <em>must not</em> interpret any <<custom-ident>> values as having a meaning;
207170
any additional recognized color schemes
208171
must be explicitly added to this property’s grammar.
209-
To avoid confusion,
172+
173+
Note: To avoid confusion,
210174
authoring tutorials and references
211175
should omit <<custom-ident>> from their materials.
212176

213-
''color-scheme/normal'', ''light'', and ''dark'' are not valid <<custom-ident>>s in this property.
214-
215-
Note: Repeating a keyword, such as ''color-scheme: light light'',
216-
is valid but has no additional effect
217-
beyond what the first instance of the keyword provides.
177+
The ''color-scheme/normal'', ''light'', and ''dark'' keywords
178+
are not valid <<custom-ident>>s in this property.
218179
</dl>
219180

181+
Note: [=Light=] and [=dark=] [=color schemes=]
182+
are not specific color palettes.
183+
For example,
184+
a stark black-on-white scheme and a sepia dark-on-tan scheme
185+
would both be considered [=light color schemes=].
186+
To ensure particular foreground or background colors,
187+
they need to be specified explicitly.
188+
189+
If the user's [=preferred color scheme=],
190+
as indicated by the 'prefers-color-scheme' media feature,
191+
is present among the listed [=color schemes=],
192+
and is supported by the user agent,
193+
that's the element's [=used color scheme=].
194+
195+
Otherwise,
196+
if the user agent supports at least one of the listed [=color schemes=],
197+
the [=used color scheme=] is
198+
the first supported [=color scheme=] in the list.
199+
200+
Otherwise,
201+
the [=used color scheme=] is the browser default.
202+
(Same as ''color-scheme/normal''.)
203+
204+
Note: User agents are <strong>not required</strong>
205+
to support any particular [=color scheme=],
206+
so only using a single keyword,
207+
such as ''color-scheme: dark'',
208+
to indicate a required [=color scheme=]
209+
is still not guaranteed to have any effect on the rendering of the element.
210+
220211
<div class=example>
221212
A well-written page--
222213
one that responds to user preferences for light or dark display
@@ -250,53 +241,55 @@ Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme
250241
affects what <<system-color>>s resolve to.
251242
</div>
252243

253-
Note: “Light” and “dark” color schemes are not specific color palettes.
254-
For example,
255-
both a stark black-on-white scheme and a sepia dark-on-tan scheme
256-
would both be considered “Light” color schemes.
257-
To ensure particular foreground or background colors,
258-
they need to be specified explicitly.
259-
260244
Note: [[HTML]] specifies a
261245
<a href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme">color-scheme</a>
262246
<{meta}> tag which can be used to set the color-scheme on the root element as
263247
a [[css-cascade-4#preshint|non-CSS presentational hint]].
264248

265-
Note: Earlier versions of this property also defined an <css>only</css> keyword
266-
to be specified alongside a preferred color scheme,
267-
indicating a stronger author preference.
268-
It ended up being unnecessary,
269-
and was removed.
249+
Note: Repeating a keyword, such as ''color-scheme: light light'',
250+
is valid but has no additional effect
251+
beyond what the first instance of the keyword provides.
270252

271253

272254
Effects of the Used Color Scheme {#color-scheme-effect}
273255
--------------------------------
274256

275257
For all elements,
276-
rendering with a [=color scheme=] should cause the colors used in all browser-provided UI for the element--
277-
e.g. scrollbars, spellcheck underlines, form controls, etc.--
278-
to match with the intent of the [=color scheme=].
258+
the user agent must match the following to the [=used color scheme=]:
259+
260+
* the used value of the [[css-color-4#css-system-colors|system colors]]
261+
* the default colors of scrollbars and other interaction UI
262+
* the default colors of form controls and other "specially-rendered" elements
263+
* the default colors of other browser-provided UI, such as "spellcheck" underlines
279264

280265
On the root element,
281-
rendering with a [=color scheme=] additionally must affect
266+
the [=used color scheme=] additionally must affect
282267
the surface color of the [=canvas=],
283268
the initial value of the '/color' property,
284-
and the used values of the [[css-color-4#css-system-colors|system colors]],
285-
and should also affect the viewport's scrollbars.
269+
and the viewport's scrollbars.
286270

287271
In order to preserve expected color contrasts,
288272
in the case of embedded documents typically rendered over a transparent [=canvas=]
289273
(such as provided via an HTML <{iframe}> element),
290-
if the used 'color-scheme' of the element
291-
and the used 'color-scheme' of the embedded document’s root element
274+
if the [=used color scheme=] of the element
275+
and the [=used color scheme=] of the embedded document’s root element
292276
do not match,
293277
then the UA must use an opaque [=canvas=] of the ''Canvas'' color
294-
appropriate to the embedded document’s 'color-scheme'
278+
appropriate to the embedded document’s [=used color scheme=]
295279
instead of a transparent canvas.
296280
This rule does not apply to documents embedded
297281
via elements intended for graphics
298282
(such as <{img}> elements embedding an SVG document).
299283

284+
Note: Aside from the small list of adjustments given above,
285+
user agents generally do not further adjust a page
286+
to match the user's preferred [=color scheme=],
287+
because the chance of accidentally ruining a page is too high.
288+
However, when particular color choices are required by the user
289+
(for accessibility reasons, for example),
290+
more invasive changes might be applied;
291+
see [[#forced]].
292+
300293

301294
Forced Color Schemes {#forced}
302295
====================

0 commit comments

Comments
 (0)