Re: [csswg-drafts] [css-color-4] HTML needs an html-compatible, hex serialization of 8 bit/component sRGB colors (#10550)

This is to allow the HTML spec [**"serialization of a color"**](https://html.spec.whatwg.org/#serialisation-of-a-color) to be replaced by a reference to CSS Color; while also updating it to cover `display-p3` because Canvas has the option of either `sRGB` or `display-p3` now.

> The serialization of a color for a color value is a string, computed as follows: if it has alpha equal to 1.0, then the string is a lowercase six-digit hex value, prefixed with a "#" character (U+0023 NUMBER SIGN), with the first two digits representing the red component, the next two digits representing the green component, and the last two digits representing the blue component, the digits being [ASCII lower hex digits](https://infra.spec.whatwg.org/#ascii-lower-hex-digit). Otherwise, the color value has alpha less than 1.0, and the string is the color value in the CSS rgba() functional-notation format: "rgba" (U+0072 U+0067 U+0062 U+0061) followed by a U+0028 LEFT PARENTHESIS, a base-ten integer in the range 0-255 representing the red component (using [ASCII digits](https://infra.spec.whatwg.org/#ascii-digit) in the shortest form possible), a literal U+002C COMMA and U+0020 SPACE, an integer for the green component, a comma and a space, an integer for the blue component, another comma and space, a U+0030 DIGIT ZERO, if the alpha value is greater than zero then a U+002E FULL STOP (representing the decimal point), if the alpha value is greater than zero then one or more [ASCII digits](https://infra.spec.whatwg.org/#ascii-digit) representing the fractional part of the alpha, and finally a U+0029 RIGHT PARENTHESIS. User agents must express the fractional part of the alpha value, if any, with the level of precision necessary for the alpha value, when reparsed, to be interpreted as the same alpha value.

-- 
GitHub Notification of comment by svgeesus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10550#issuecomment-2220334410 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 10 July 2024 12:02:56 UTC