Skip to content

[css-color-adjust] [css-color-adjust] Initial value of the color property. #9274

Closed
@emilio

Description

@emilio

Consider this test-case (live):

<!doctype html>
<html style="color-scheme:dark">Root
  <div style="color:red">child div
    <span style="color: initial">what color is this span?</span>
    <span style="color: initial; color-scheme: light">And this?</span>
  </div>
</html>

Browsers disagree on what the behavior is:

  • In Firefox and Safari, the initial color value is still black.
  • In Chrome, the initial color behaves like an explicit CanvasText.

Right now the specs specify neither behavior.

From https://drafts.csswg.org/css-color-4/#the-color-property:

Initial: CanvasText

Initial values are generally computed values, which means that you use the default color scheme, which comes from the <meta name=color-scheme> tag, absent in this test-case.

But then from https://drafts.csswg.org/css-color-adjust/#color-scheme-effect:

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.

Which I understand it as "the second span should still have white text".

Test-case with <meta name=color-scheme> here for reference.

I think all browser's behavior make some sense in a way, and are reasonably easy to implement (Chromium's behavior seems to be some sort of special-case where they treat initial much like CanvasText). But the spec behavior is rather weird.

I think Chromium's behavior is the most intuitive and would be ok resolving to do that, but happy to hear other opinions.

@lilles it seems this comes from a647cfd which seems directly from your spec draft. Is the spec behavior being different from Chromium's behavior intentional? I'm guessing not? :)

cc: @smfr @jfkthame @svgeesus @tabatkins

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Unslotted

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions