@@ -30,12 +30,12 @@ Introduction {#intro}
30
30
related to controlling how/when colors are auto-adjusted
31
31
by the user agent:
32
32
33
- * The concept of [=color schemes=]
33
+ * [=Color schemes=]
34
34
and the 'color-scheme' property,
35
35
which controls whether or not browser-provided parts of the page's UI
36
36
respect the user's chosen [=color scheme=] .
37
37
38
- * The concept of [=forced colors mode=]
38
+ * [=Forced colors mode=]
39
39
and the 'forced-color-adjust' property,
40
40
which controls whether or not [=forced colors mode=] is allowed to apply to a given element.
41
41
@@ -66,31 +66,30 @@ Preferred Color Schemes {#preferred}
66
66
=======================
67
67
68
68
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>
70
70
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
72
72
of its navigation interface as well as in-page interface elements
73
73
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=] .
76
76
77
77
A UA can also allow the user to indicate a preference
78
78
for the [=color scheme=] of the pages they view,
79
79
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;
81
81
users can have preferences for operating system interface colors
82
82
that they do not want imposed on pages.)
83
83
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:
92
85
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=]
94
93
don't represent an exact color palette (such as black-and-white),
95
94
but a range of possible palettes.
96
95
To guarantee specific colors, authors must specify those colors themselves.</strong>
@@ -100,37 +99,19 @@ Preferred Color Schemes {#preferred}
100
99
it might be necessary to set both foreground and background colors together
101
100
to ensure legibility [[WCAG21]] .
102
101
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=] ,
104
103
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.
119
109
120
110
User agents <em> may</em> support additional [=color schemes=] ,
121
111
however CSS does not support negotiation of additional [=color schemes=] :
122
112
user agents should pursue standardization of these schemes,
123
113
so that '@media/prefers-color-scheme' and 'color-scheme' can reflect the additional values.
124
114
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
-
134
115
Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme-prop}
135
116
-----------------------------------------------------------------
136
117
@@ -152,9 +133,10 @@ Opting Into a Preferred Color Scheme: the 'color-scheme' property {#color-scheme
152
133
which [=color schemes=] it is designed to be rendered with.
153
134
These values are negotiated with the user's preferences,
154
135
resulting in a <dfn export>used color scheme</dfn>
155
- that affects UI things such as
136
+ that affects things such as
156
137
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]] .)
158
140
159
141
Note: Because many pages were authored before color scheme support existed,
160
142
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
168
150
Indicates that the element isn't aware of [=color schemes=] at all,
169
151
and so the element should be rendered with the browser's default [=color scheme=] .
170
152
171
- : <dfn lt="light | dark">[ light | dark | <<custom-ident>> ]+ </dfn>
153
+ : <dfn> light</dfn>
172
154
::
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=] .
201
157
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
+ ::
202
165
<<custom-ident>> values are meaningless,
203
166
and exist only for future compatibility,
204
167
so that future added color schemes do not invalidate the 'color-scheme' declaration
205
168
in legacy user agents.
206
169
User agents <em> must not</em> interpret any <<custom-ident>> values as having a meaning;
207
170
any additional recognized color schemes
208
171
must be explicitly added to this property’s grammar.
209
- To avoid confusion,
172
+
173
+ Note: To avoid confusion,
210
174
authoring tutorials and references
211
175
should omit <<custom-ident>> from their materials.
212
176
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.
218
179
</dl>
219
180
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
+
220
211
<div class=example>
221
212
A well-written page--
222
213
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
250
241
affects what <<system-color>> s resolve to.
251
242
</div>
252
243
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
-
260
244
Note: [[HTML]] specifies a
261
245
<a href="https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme">color-scheme</a>
262
246
<{meta}> tag which can be used to set the color-scheme on the root element as
263
247
a [[css-cascade-4#preshint|non-CSS presentational hint]] .
264
248
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.
270
252
271
253
272
254
Effects of the Used Color Scheme {#color-scheme-effect}
273
255
--------------------------------
274
256
275
257
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
279
264
280
265
On the root element,
281
- rendering with a [= color scheme=] additionally must affect
266
+ the [=used color scheme=] additionally must affect
282
267
the surface color of the [=canvas=] ,
283
268
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.
286
270
287
271
In order to preserve expected color contrasts,
288
272
in the case of embedded documents typically rendered over a transparent [=canvas=]
289
273
(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
292
276
do not match,
293
277
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=]
295
279
instead of a transparent canvas.
296
280
This rule does not apply to documents embedded
297
281
via elements intended for graphics
298
282
(such as <{img}> elements embedding an SVG document).
299
283
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
+
300
293
301
294
Forced Color Schemes {#forced}
302
295
====================
0 commit comments