Setting "color" property to "initial" value sets default browser color instead of dark scheme color when "color-scheme" property has "dark" value.
Categories
(Core :: CSS Parsing and Computation, defect, P3)
Tracking
()
People
(Reporter: mistertoups, Unassigned)
References
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0
Steps to reproduce:
Set CSS "color-scheme" property to "dark" on the :root element.
On an element in the document, set "color" property to any literal color value, such as "red" or "transparent".
On a child of that element, set "color" property to "initial".
Actual results:
The child element's computed browser style for color shows: "rgb(0,0,0)" and is rendered accordingly.
Expected results:
The child element's computed value for "color" should match the root element's browser color value when using "color-scheme: dark" (in my case, "rgba(251, 251, 254)" and should be rendered accordingly. From the CSS Spec (emphasis mine):
"On the root element, the used color scheme additionally must affect the surface color of the canvas, the initial value of the color property, and the viewport’s scrollbars."
(source: https://drafts.csswg.org/css-color-adjust/#color-scheme-effect)
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•3 years ago
|
Comment 2•3 years ago
|
||
The severity field is not set for this bug.
:jfkthame, could you have a look please?
For more information, please visit BugBot documentation.
Comment 3•3 years ago
|
||
Small testcase:
data:text/html,<html style="color-scheme:dark">Root <div style="color:red">child div <span style="color:initial">what color is this span?
This gives me black-on-black text (i.e. invisible) for the <span>.
However, it's not clear to me that this is a bug. Look again at the CSS spec:
On the root element, the used color scheme additionally must affect the surface color of the canvas, the initial value of the color property, and the viewport’s scrollbars.
(emphasis mine). It specifically refers to on the root element, but this example is applying color: initial to a child element, not the root, and so that sentence isn't applicable.
FWIW, Safari behaves the same as Firefox here. (Chrome, on the other hand, gives white-on-black for the <span>, i.e. it does allow the color scheme to affect the initial value for color, even though it's not on the root element.)
It may be worth raising this as a CSS spec issue, as browsers obviously have different behaviors at present, and at first glance the Chrome behavior seems preferable at least in this simple case. But it's not what the spec says.
Emilio, ISTR you've done some color-scheme work; do you have any further insight here?
Comment 4•3 years ago
|
||
It's a bit unfortunate to make the initial keyword do something special based on the root color scheme. Chromium's behavior doesn't seem quite that tho. We honor it for the color-scheme meta tag, which is document-wide...
Anyways, I filed https://github.com/w3c/csswg-drafts/issues/9274, this probably deserves further discussion.
Description
•