Skip to content

[css-color-4] a new property to limit to a specific color gamut #10038

@romainmenke

Description

@romainmenke

see : #9449 (comment)

@ccameron-chromium said :

If an author specifies content that is far outside of what their screen can reproduce, then there is no way to avoid having them be surprised when that content is accurately rendered on a more capable screen.

This is very much a "the only winning move is not to play" situation. We shouldn't be giving authors tools where it is extremely easy to unintentionally specify such colors. But we did, in the lab, lch, oklab, and oklch spaces. The oklab and oklch spaces are excellent for perceptually uniform interpolation, but they are dangerous for color manipulation, because there are no guardrails for staying in-gamut. The relative-color syntax exacerbates this.

The problem that I want for us to focus on solving here is how to avoid having authors specify colors that are far beyond their display's capability to produce.

If we don't solve that problem then authors will inevitably face the above-described surprise.

If we don't solve that problem then we also have to solve the problem of assigning meaning to colors that are physically meaningless or far beyond the capabilities of any current display.


This comment was made in the context of gamut mapping for colors when those colors go beyond the device capability.

While I don't agree with that line of thinking, I do think there is something here and I want to explore it from a different perspective.


There is a disconnect between:

  • what authors describe
  • what they can observe today
  • what their intention was
  • how values will be displayed in x years on vastly superior hardware.

Authors can easily write CSS that produces color values that are outside specific color gamuts.
With interpolation, animations, relative color, ... this can often happen without the author noticing at the time of writing that specific code.

Should it be possible for authors to force a document and/or element to gamut map all colors to a specific gamut?

Maybe through a new property :

:root {
  max-color-gamut: display-p3;
}

Authors would then be able to use things like interpolation in lch without having to worry about unexpected outcomes on future hardware.

It gives you access to the color models behind oklch, lch, ... without having to think about what happens when values go beyond your design constraints.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions