Gamut mapping — clipping and chroma reduction are not the same
A colour outside the gamut cannot be shown as it is. Browsers and tools replace it with the closest displayable colour, and that process is gamut mapping. The problem is that “closest” has several definitions: clipping each RGB channel, reducing chroma, or compressing the whole palette. Each produces a different result.
Four methods
| Method | What it does | Side effect |
|---|---|---|
| Channel clipping | clamps channels outside 0–1 to 0 or 1 | shifts hue and crushes neighbouring shades together |
| Chroma reduction | keeps L and H, lowers C until it fits | most predictable; only saturation drops |
| Perceptual compression | scales the whole palette into the gamut | every colour moves, palette balance survives |
| Relative colour | browser maps to the display gamut | slightly different per browser |
Channel clipping is the fastest and the worst. When the blue channel clamps at 1, lightness and hue both shift, and two adjacent colours can collapse into one. CSS gamut mapping is not simple clipping for exactly this reason.
The calculator reduces chroma
For every step outside the gamut the calculator keeps L and H and binary-searches C between zero and the requested value. Twenty-eight iterations put the error around 1e-9, which is exact enough. The advantage is predictability: it can report how much chroma was clipped, and other steps of the same hue stay aligned.
lo = 0, hi = C
repeat 28 times:
mid = (lo + hi) ÷ 2
if mid is inside sRGB: lo = mid, else hi = mid
result C = lo
The resulting hex is an approximation. On a P3 display the original oklch() value survives, so the code carries both the hex and the oklch() value, separated by @supports. That is exactly what the export produces.
When clipping is defensible
Chroma reduction is not always the answer. In photographs and gradients, where colour changes continuously, clipping can look more natural. In UI tokens, where colours are discrete and their relationships matter, chroma reduction is better. The test is whether the relationship between colours carries meaning.
A short checklist
- Count the steps outside the gamut. More than five suggests lowering chroma.
- Compare the hex fallback with the original: a chroma difference above 0.04 reads as a different colour.
- Keep brand colours inside sRGB so logo files and CSS agree.
- Screens without P3 are still common; never ship a P3-only palette without fallbacks.
Mapping behaviour follows the CSS Color 4 gamut mapping section and Ottosson's OKLab discussion.
Questions
How does a browser handle an out-of-gamut oklch()?
It maps the colour to the display gamut. Current browsers consider perceptual distance rather than simple clipping, but implementations differ slightly.
Should I lower chroma or lightness first?
For UI palettes, chroma. Changing lightness also disturbs contrast and the step relationships.
Is there a case for deliberately out-of-gamut colour?
Yes: accents and decoration that should look vivid on P3 screens. Always define the hex fallback with it.
Raise chroma and see which step clips first in the palette tab.
Open the toolBasis date 28 November 2026. Written against the W3C specifications, the APCA documentation and published browser support tables; updated when they change.
Back to the guides