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

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

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Sun, 22 Dec 2019 18:11:56 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-568289507-1577038315-sysbot+gh@w3.org>
I'm not sure that adding a dependency to `background-color` is a good idea.

But if it's done, I would say that it would be better to go all the way, expose `backgroundColor` in `<color>`, handle cyclic dependencies like for `var()`, and cover your usecase with [`color-contrast`](https://drafts.csswg.org/css-color-5/#colorcontrast):

color: color-contrast(backgroundColor white, black)

@frivoal proposed `backgroundColor` in #364, but it was rejected because `background-color` is not inheritable and usually you want the background of some ancestor, not the element itself.

But you can use variables:

--background-color: #123456;
background-color: var(--background-color);
color: color-contrast(var(--background-color) white, black);

GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4623#issuecomment-568289507 using your GitHub account
Received on Sunday, 22 December 2019 18:11:59 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:57 UTC