Skip to content

[css-color-5] Serialization of origin colors does not match WPT or implementations #14950

Backlog

Description

@svgeesus

§ Serializing Origin Colors disagrees with WPT, and mostly with what browsers do, about how the declared value of an absolute color used as an origin color is serialized.

The spec says to keep the color function and serialize its components as specified, in modern syntax, with percentages staying percentages and no clamping. The tests expect these origin colors to be normalized, much as they would be outside a relative color:

Specified origin color Per spec Expected by tests
hsl(120 50% 50%) unchanged rgb(64, 191, 64)
hwb(120 0% 0%) unchanged rgb(0, 255, 0)
hsl(120deg 20% 50% / .5) hsl(120 20% 50% / 0.5) rgba(102, 153, 102, 0.5)
rgb(20%, 40%, 60%, 80%) rgb(20% 40% 60% / 80%) rgba(51, 102, 153, 0.8)
lch(50% 20 30) unchanged lch(50 20 30)
lab(200 300 400 / 500%) lab(200 300 400 / 500%) lab(100 300 400)

The tests are alpha-color-parsing-valid and color-valid-relative-color. Origin colors which are themselves relative colors are expected to be preserved.

The tests also contradict the spec examples, which keep an hsl() origin color as hsl(), including out-of-range values:

hsl(from hsl(127.9 302% 25.33%) h s l)

On wpt.fyi (experimental runs of 4 December 2026), Chrome 161 and Safari 257 preview pass the subtests in both files which have these origin colors. Firefox 164 does too, apart from some where an rgb() origin color contains none.

The spec text was adopted by resolution in #10328, which is still open; a comment there noted that some tests had not been updated.

Options:

  1. Keep the spec, update the tests, and ask implementations to change.
  2. Change the spec to match implementations.

See also #14949, about the channel and alpha arguments of the relative color itself, and #10328, about serializing nested colors in their most precision saving form

Activity

  1. added
    css-color-5
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    css-color-5

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions