W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2019

[csswg-drafts] [css-color] Adaptive Color Keywords black-or-white and white-or-black (#4623)

From: Christoph Päper via GitHub <sysbot+gh@w3.org>
Date: Fri, 20 Dec 2019 15:59:05 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-541065680-1576857543-sysbot+gh@w3.org>
Crissov has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-color] Adaptive Color Keywords black-or-white and white-or-black ==
If `invert` (optionally) depended on the value of `background-color` #4611 and was added to other properties than `outline-color`, but perhaps not to the `<color>` type itself, there would be some other useful color keywords defined in a similar way:

- **`white-or-black`** equals `black` if the value of `background-color` has a CIE lightness of more than 40%, otherwise it equals `white`
- **`black-or-white`** equals `white` if the value of `background-color` has a CIE lightness of less than 60%, otherwise it equals `black`

I am not sure whether they should depend on the specified, computed, actual or used value. The thresholds of 40% and 60% are chosen arbitrarily; with 50% there would be no need for two different keywords.

This could be used, for instance, in color swatch tables where the background shows the sample color and the text gives the color name or code value, and it would thus ensure readability.

Perhaps there could also be a point made in favor of `current-or-black` and `current-or-white` keywords, which would not depend on the absolute lightness of the background color but on the contrast ratio between that and `currentcolor`.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4623 using your GitHub account
Received on Friday, 20 December 2019 15:59:07 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:27:06 UTC