Skip to content

CSS color serialization and <input type=color> with alpha/colorspace #11008

Open
@annevk

Description

@annevk

For whatwg/html#10456 we allow <input type=color>'s internal color to be set as follows:

  • An arbitrary value that parses as a CSS color (value attribute).
  • An end user selected CSS color through some UI.

This color is then color space converted depending on the colorspace attribute and serialized for API purposes and form submission. We only support the 'srgb' and 'display-p3' color spaces for now.

When colorspace is set to "limited-srgb" (default value) and the alpha attribute is not set we specifically instruct CSS color serialization to use the hexadecimal syntax for compatibility.

Otherwise we follow CSS color serialization directly.

However, what is not clear currently is what kind of normalization color space conversion applies. E.g., if the input is lab(51.2345% -13.6271 16.2401), is the output going to be color(srgb 0.41587 0.503670 0.36664)? How is that defined? What if the input is #11223344?

Ideally from a web developer perspective I think it would always use color(srgb ...) or color(display-p3 ...) unless we needed compatibility with the existing input as described above. But now I'm wondering if that is actually what we ended up requiring or if there are some other loose ends to tighten up.

cc @svgeesus @lukewarlow @weinig

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions