CSS Color Gamuts, Color Spaces and color-mix
How CSS Color 4 wide gamuts, color() and color-mix() work, which space to pick for gradients, and how to verify HD color on your site.
This page summarises Chrome for Developers documentation on CSS Color Level 4 and related tools: why the web moved beyond sRGB, how color gamuts and color spaces differ, how to specify wide-gamut colors with color(), mix and tune colors with color-mix(), and how gradient interpolation chooses a space (often oklab by default).
For decades, CSS colors lived inside sRGB—hex, rgb(), hsl(), and named colors all reference the same narrow gamut. Modern phone, laptop, and TV displays can show a much wider range. CSS Color 4 adds syntax and spaces so styles can match those displays and produce smoother gradients and more predictable color math.
Color gamut vs color space: range vs arrangement
Section titled “Color gamut vs color space: range vs arrangement”A color gamut is the range of colors available—what people often mean by “millions of colors” on a display. A color space is how that range is arranged: the shape (cube, cylinder) and the syntax you use to pick coordinates inside it.
A color space is a mapping of colors where a color gamut is a range of colors. Consider a color gamut as a total of particles and a color space as a bottle made to hold that range of particles.
— Chrome for Developers, High definition CSS color guide
Gamuts are often drawn as triangles inside the human visual gamut (HVS). The classic rgb() triangle sits inside a much larger horseshoe of visible color. Industry names—sRGB, Display P3, Rec. 2020—let you talk about “how big” a range is without listing every coordinate.
| Term | Use it when you mean… |
|---|---|
| Gamut | How many / how vivid colors a display or syntax can reach (e.g. “wide gamut”) |
| Color space | How to write and interpolate colors (hsl(), oklch(), color(display-p3 …)) |
Use gamut language for hardware and capability; use color-space language for CSS syntax, manipulation, and gradients. The High definition CSS color guide expands this with classic sRGB spaces (hex, RGB, HSL, HWB) and points to Access more colors and new spaces for the Level 4 additions.
CSS Color 4 color spaces: wide gamut and perceptual models
Section titled “CSS Color 4 color spaces: wide gamut and perceptual models”CSS Color Level 4 adds 12 new color spaces on top of the older sRGB-only set. They fall into three practical groups: RGB-based wide gamuts (via color()), CIE perceptual spaces (dedicated functions), and reference XYZ spaces.
color() function: one syntax for RGB-type spaces
Section titled “color() function: one syntax for RGB-type spaces”The color() function takes a color-space name first, then channel values (and optional alpha). It normalises access to any space that specifies colors with R, G, B channels.
The new color() function can be used for any color space that specifies colors with R, G, B channels. color() takes a color space parameter first, then a series of channel values for RGB and optionally some alpha.
— Chrome for Developers, Access more colors and new spaces
color() does not apply to hsl(), hwb(), lch(), oklch(), or oklab()—those keep their own functions.
Common color() spaces from the docs:
| Space keyword | Role |
|---|---|
srgb |
Same gamut as rgb(); allows 0–1 decimals as well as percentages |
srgb-linear |
Linear-light RGB; predictable for engines, but not perceptually uniform |
display-p3 |
Popular wide gamut (~50% more colors than sRGB); common on Apple displays since 2015 |
rec2020 |
UHDTV-oriented; largest common RGB gamut in the set but rare on handhelds |
a98-rgb, prophoto-rgb |
Print/photo workflows; ProPhoto can include non-visible “imaginary” colors |
xyz, xyz-d50, xyz-d65 |
CIE reference; covers full HVS; white point differs between d50 and d65 |
The display-p3 color space offers almost twice as many colors as RGB, while Rec2020 offers almost twice as many as display-p3.
— Chrome for Developers, Access more colors and new spaces
LCH, LAB, OKLCH, OKLAB: perceptual lightness and chroma
Section titled “LCH, LAB, OKLCH, OKLAB: perceptual lightness and chroma”LCH and LAB expose the full CIE gamut with a perceptually linear lightness axis—unlike HSL “lightness,” which does not stay constant across hues.
- LCH: lightness, chroma, hue (angle). Easy vibrant gradients; high chroma can exceed the display gamut.
- LAB: L plus red–green (a) and blue–yellow (b) axes; consistent gradients but awkward to hand-author and prone to hue shift.
- OKLCH / OKLAB: “Corrected” variants; OKLAB is the spec’s default for animations and interpolations and avoids much of LAB’s hue shift.
This space is claimed as a space optimized for image processing quality also, which for us in CSS means gradients and color function manipulation quality.
— Chrome for Developers, Access more colors and new spaces (on OKLAB)
Which space should you pick?
Section titled “Which space should you pick?”There is no single “best” space. The Access more colors and new spaces conclusion treats CIE spaces (lab, oklab, lch, oklch) as typical starting points: OKLCH for UI color systems, OKLAB for mixing and gradients (also the default for color-mix() and cross-space gradients). Display P3 is a practical first wide gamut when stepping up from sRGB. Rec. 2020 suits ultra-HD content more than everyday UI.
color-mix(): mix colors in a chosen space
Section titled “color-mix(): mix colors in a chosen space”Before color-mix(), lightening or darkening in pure CSS often meant preprocessors or calc() on HSL channels. color-mix() mixes two <color> values in a named space with optional percentages.
The CSS color-mix() function lets you mix colors, in any of the supported color spaces, right from your CSS.
— Chrome for Developers, CSS color-mix()
Because spaces rearrange color differently, you must specify the space—the same two paints can look pink, purple, or neutral gray depending on in srgb vs in oklab.
color-mix(in oklab, blue, white);color-mix(in srgb, blue, white);The default mixing (and gradient) space is oklab, chosen for consistent, expectation-aligned results (e.g. blue + white without a purple middle). For vivid blends (magenta + lime), HSL or HWB may look more saturated; for subtle darkening (blue + black), oklab tends to stay stable.
Ratios, transparency, and cross-syntax mixes
Section titled “Ratios, transparency, and cross-syntax mixes”- Omit percentages for a 50/50 mix; one-sided percentages assign the remainder to the other color.
- If ratios sum above 100%, they are equally clamped to total 100%.
- If both ratios sum below 100%, the result is partially transparent (neither color fully applied).
color-mix() can combine different syntaxes in one call—the mix space converts both operands first:
color-mix(in oklch, hsl(200deg 50% 50%), color(display-p3 .5 0 .5));Hue interpolation in cylindrical spaces
Section titled “Hue interpolation in cylindrical spaces”For spaces with a hue angle (lch, oklch, hsl, hwb), you can set hue path: shorter, longer, increasing, or decreasing. That option is a syntax error on non-cylindrical spaces. Details overlap with gradient hue control in Access more colors and new spaces and CSS color-mix().
Gradients and interpolation: dead zones, hue paths, and bit depth
Section titled “Gradients and interpolation: dead zones, hue paths, and bit depth”Gradients and animations interpolate between stops. With Color 4, you can write linear-gradient(in hsl to right, blue, white) so interpolation runs in HSL instead of default sRGB—often a visibly different path.
Default interpolation space
Section titled “Default interpolation space”When stops use different color spaces, the browser picks a common space. Unless you set in <space> on the gradient, that default is oklab:
/* oklab is the common space */background: linear-gradient(to right, lch(29.6 131 301), hsl(330 100% 50%));
/* force interpolation in lch */background: linear-gradient(in lch to right, lch(29.6 131 301), hsl(330 100% 50%));Dead zone and extra stops
Section titled “Dead zone and extra stops”In cylindrical spaces, a straight interpolation line can cut through the center of the space where chroma is low—the dead zone—so mid-gradient colors look gray or dull. Mitigations include extra stops (tools such as Erik Kennedy’s gradient helper, mentioned in Access more colors and new spaces) or hue interpolation keywords in Color 4, e.g. longer hue or decreasing hue in hsl.
16-bit floating-point channels (versus old 8-bit packing) support HD color and reduce gradient banding when many in-between values are needed.
Visual effects guidance for production UI:
- Prefer
in oklchwhen you want chroma preserved but accept more out-of-gamut risk on large hue/lightness jumps. - Prefer
in oklabfor in-gamut, perceptually even blends; middle hues can look desaturated between opposites. - Avoid
in srgbunless you deliberately want legacy behavior (e.g. a picker that must match old math).
For browsers without in oklab / in oklch gradient syntax, the same guide shows an @supports token fallback so the gradient still parses—color-mix() does not need that pattern when the browser supports color-mix() at all.
Migrate to HD color: degradation vs progressive enhancement
Section titled “Migrate to HD color: degradation vs progressive enhancement”Migrate to HD CSS color describes two strategies:
| Strategy | Idea | Trade-off |
|---|---|---|
| Graceful degradation | Declare wide-gamut colors; browser maps/clamps to the display | Simplest; final color may not match your intent on narrow screens |
| Progressive enhancement | Layer @supports and @media so HD syntax applies only when supported |
More CSS to maintain; finer control |
A common progressive pattern checks display capability and parser capability:
:root { --neon-red: rgb(100% 0 0);}
@media (dynamic-range: high) { @supports (color: color(display-p3 0 0 0)) { --neon-red: color(display-p3 1 0 0); }}Feature detection (also from Migrate to HD CSS color):
@media (color-gamut: p3)/rec2020/srgb— approximate display gamut (privacy-preserving, not exact hardware).@media (dynamic-range: high)— HDR-oriented styling.@supports (background: oklch(0 0 0))— whether the engine parses a given space.window.matchMedia('(color-gamut: p3)').matchesandCSS.supports('background: color(display-p3 0 0 0)')— the same checks from JavaScript.
Pairing a fallback red (or rgb()) with color(display-p3 …) lets unsupported browsers keep the last understood declaration.
Chrome DevTools: pick, convert, and debug HD colors
Section titled “Chrome DevTools: pick, convert, and debug HD colors”Inspect and debug HD and non-HD colors with the Color Picker documents tooling that matches the new spaces:
- Display value switcher (or Shift-click the swatch) lists hex,
rgb,hsl,hwb,lch,oklch,lab,oklab, andcolor(<space> …)forms. - Gamut boundary line separates sRGB from Display P3 when a space can express both HD and non-HD coordinates.
- Converting toward a smaller gamut clips values; DevTools shows a warning and tooltip with the pre-clip value.
color-mix()gets inline preview and editing in the Styles pane (CSS color-mix()).
To emulate what a user agent might report for gamut, open the Rendering panel and set Emulate CSS media feature color-gamut to srgb, p3, or rec2020 (Emulate CSS media features).
Common mistakes
Section titled “Common mistakes”- Mixing or grading in sRGB by habit — blue-to-white gradients and
color-mix(in srgb, …)often show purple or pink mids; tryoklabor specifyin oklchwhen vibrancy matters. - Ignoring gamut on displays — ultra-high chroma in
lch()/oklch()requests colors that clamp on sRGB hardware; verify with the gamut line in DevTools. - Assuming HSL lightness is perceptual — for consistent ramps across hues, use LCH/OKLCH lightness (High definition CSS color guide).
- Hue keywords on LAB/OKLAB —
longer hueand friends apply only to cylindrical spaces; elsewhere they are invalid incolor-mix(). - HD-only declarations without fallback — always cascade a known sRGB color before
color(display-p3 …)if you need older engines to render something (Migrate to HD CSS color). - Broken gradient fallback — if you use the
--in-oklabtoken trick, keep a validlinear-gradient(...)without the token so pre-2024 parsers do not see a syntax error (Visual effects).
Further reading in the same doc set: CSS and UI hub, CSS features reference (color picker entry), and interactive demos linked from High definition CSS color guide (e.g. Codepen comparison).
How to check this on your site
Section titled “How to check this on your site”- In Chrome, open DevTools → Rendering, set Emulate CSS media feature
color-gamuttop3orrec2020, then reload and compare key UI colors (Emulate CSS media features). - Inspect accent colors with the Color Picker: confirm whether values sit inside the gamut boundary line and whether conversion warnings appear when switching to
rgbor hex. - Add temporary rules such as
color-mix(in oklab, var(--brand), white 40%)and confirm the preview matches intent in the Styles pane (CSS color-mix()). - In the console, run
CSS.supports('background: color(display-p3 0 0 0)')andmatchMedia('(color-gamut: p3)').matchesalongside your@supports/@mediablocks (Migrate to HD CSS color). - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about so it can be corrected.