Skip to content

Serialize hsl and hwb percentages with a percent sign - #237

Open
mamicicekel wants to merge 2 commits into
linebender:mainfrom
mamicicekel:fix/hsl-hwb-percent-serialization
Open

mamicicekel wants to merge 2 commits into
linebender:mainfrom
mamicicekel:fix/hsl-hwb-percent-serialization

Conversation

@mamicicekel

@mamicicekel mamicicekel commented Nov 5, 2026 •

Copy link
Copy Markdown

Fixes #229.

Display for an Hsl color used the comma-separated legacy form but omitted the % units on saturation and lightness, so the string was hsl(120, 50, 25). CSS Color 4 requires those units in the legacy syntax (hsl(120, 50%, 25%)). hwb() has the same gap: whiteness and blackness were written as bare numbers (hwb(120 30 50)) even though the modern syntax requires percentages.

none is not allowed in the legacy comma form, so an hsl() color with a missing component is serialized with the modern syntax instead (hsl(120 none 25%)).

Legacy hsl() requires % on saturation and lightness, and hwb() requires
% on whiteness and blackness. A missing hsl component uses the modern
form, which is the syntax that can represent none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Serializing Hsl colors uses a broken legacy syntax

1 participant