Description
A common theme came up in discussions of #3853 (about sepia
), #3849 (about normal
not always being the same as light
) and #3859 (about an any
option for the color-scheme
property): light
and dark
themes don't always have to be the same from browser to browser. But a web page author needs confidence that if they say they support the theme, it won't result in a broken site.
To me, the most important way something can be “broken” by colors is if it fails contrast minimums.
I therefore propose that we include explicit requirements for browser's built-in light & dark schemes, based on the WCAG contrast formula. For example, for light
mode we could say:
-
The default canvas color (and new
canvas
system color) must meet AAA contrast for all text sizes when compared against#333
text. -
The default text color (
text
color keyword) must meet AAA contrast for all text sizes when compared against#ccc
background color.
A dark
scheme would have the requirements reversed.
That way, an author could use the built-in light
theme canvas color and set their own text colors, knowing the contrast will be good enough so long as their chosen text colors are at least as dark as #333
(or whatever cut-offs we choose).
Now, only talking about contrast leaves a lot of room to move. Maybe too much. A yellow
on darkblue
scheme would meet the definition of a dark
scheme above, but it might clash on many websites designed for current dark mode schemes. So maybe we also want maximum saturation level or other restrictions.
But my point is, if we want to allow authors to use a color-scheme but selectively override parts of it, they need to know what they can expect. So, while we may also want to keep a broad definition of what light & dark mean (possibly broad enough that light
could include sepia schemes), we need to limit how broad it can get.
Spec links:
https://drafts.csswg.org/css-color-adjust-1/#preferred
https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme