Skip to content

[css-color-5] Serialization of percentages and out-of-range alpha in relative colors does not match WPT or implementations #14949

Backlog

Description

@svgeesus

§ Serializing Relative Color Functions disagrees with WPT, and with what browsers do, about how the declared value of the channel and alpha arguments is serialized.

The spec says:

  • "numbers and percentages serializing as numbers"
  • the alpha component uses "the same rules as the color channel arguments, but clamped"

The tests expect percentages to stay percentages, and out-of-range alpha to stay unclamped:

Specified value (also the expected serialization) Per spec Test
alpha(from red / 50%) alpha(from red / 0.5) alpha-color-parsing-valid
alpha(from red / 2) alpha(from red / 1) same
alpha(from red / -1) alpha(from red / 0) same
rgb(from rebeccapurple r g b / 20%) rgb(from rebeccapurple r g b / 0.2) color-valid-relative-color
rgb(from rebeccapurple 20% g b / alpha) 20% becomes a number same

The same file also expects out-of-range alpha such as / 500 and / -500 to be preserved.

On wpt.fyi (experimental runs of 4 December 2026: Chrome 161, Firefox 164, Safari 257 preview), all three pass all of alpha-color-parsing-valid, and pass the percentage and out-of-range alpha subtests of color-valid-relative-color.

Background:

Options:

  1. Change the spec to match implementations: serialize channel and alpha arguments as specified (percentages as percentages), without clamping alpha.
  2. Keep the spec, change the tests, and ask implementations to change.

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