Skip to content

Commit

Permalink
[css-color-5] Simplify contrast-color(), per WG resolution. #11534 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins authored Feb 4, 2025
1 parent affbded commit 1ccd616
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions css-color-5/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2606,23 +2606,17 @@ or any other color or monochrome output device which has been characterized.
the surrounding colors, etc.

<pre class='prod'>
<dfn export>contrast-color()</dfn> = contrast-color( <<color>> max? )
<dfn export>contrast-color()</dfn> = contrast-color( <<color>> )
</pre>

If ''max''' is specified, the function computes to ''white'' or ''black'',
depending on which of the two produces _maximum_ color contrast for text when the input color is used as a solid background.
If both colors produce the same contrast, the function should return ''white''.

If ''max''' is omitted, the function computes to a <em>very light</em> or <em>very dark</em> color (which <em>may</em> still be white or black),
which will contrast well with the input color when used as a text color and the input color is used as a solid background.
The function MUST return a light color if it would have returned ''white'' if ''max'' were specified,
and a dark color if it would have returned ''black'' if ''max'' were specified.

Note: The precise requirement for how close these colors need to be to white and black
and what color difference measure to use for that are still under discussion.
''contrast-color()'' resolves to either ''white'' or ''black'',
whichever produces <strong>maximum</strong> color contrast for text
when the input color is used as a solid background.
If both ''white'' and ''black'' produce the same contrast,
it resolves to ''white''.

The precise color contrast algorithm for determining whether to output a light or dark color
is UA-defined at this level, as is the precise color produced when ''max''' is omitted.
is UA-defined at this level.

Note: Future versions of this specification are expected to introduce more control over
both the contrast algorithm(s) used, the use cases, as well as the returned color.
Expand Down

0 comments on commit 1ccd616

Please sign in to comment.