Modern CSS color spaces such as oklch() and lab() describe colors by how humans see them, not by how a screen mixes red, green and blue light. oklch() uses lightness, chroma (colorfulness) and hue, and it is perceptually uniform, so equal numeric steps look like equal visual steps. It can also reach colors outside sRGB on wide-gamut displays, which is why css oklch is now a common choice for design tokens and palettes.
This guide explains what a color space is, how lab(), lch(), oklab() and oklch() differ, and how to use them safely with fallbacks.
Hex, rgb() and hsl() all live in the sRGB space, which was designed for old monitors. Two limits matter in practice:
hsl(60 100% 50%) (yellow) looks far brighter than hsl(240 100% 50%) (blue) although both have 50% lightness. Building a palette by keeping the L value the same gives uneven results and unreliable contrast.Perceptual color spaces fix the second problem by modelling human vision, and wide-gamut support fixes the first.
CSS Color Level 4 added several functions. All of them accept alpha after a slash.
| Function | Parameters | Notes |
|---|---|---|
lab() | L (0-100), a, b | CIE Lab, device independent, older model |
lch() | L, chroma, hue | Polar form of lab() |
oklab() | L (0-1), a, b | Improved model by Bjorn Ottosson |
oklch() | L (0-1 or %), chroma, hue | Polar form of oklab(), best for design work |
color() | space name, channels | For display-p3, rec2020 and others |
Lab models colors with one lightness axis and two opponent axes, a (green to red) and b (blue to yellow). The LCH and OKLCH variants express the same color as lightness, chroma and hue, which is more natural to edit.
oklch(L C H) has three parts:
Because lightness really is perceptual, colors with the same L look equally bright, whatever the hue.
Steps in L give a ladder of shades with predictable contrast: any two colors that are 0.4 apart in L work well as text and background. Changing --h produces a new palette with the same brightness structure, which is hard to do in HSL.
Not every combination of L, C and H exists on a given screen. A color that is outside the display gamut is mapped to the nearest displayable color, using the CSS gamut mapping algorithm, so very high chroma values may look the same on an sRGB monitor but vivid on a Display P3 screen. In developer tools you can check whether a color is inside sRGB or P3. When you are not sure, lower the chroma.
oklch(), oklab(), lab() and lch() are supported in current versions of Chrome, Edge, Safari and Firefox, but older browsers ignore them. A declaration with an unknown value is dropped, so use the cascade for a fallback:
You can also test with @supports (color: oklch(0 0 0)) when you want to group a block of rules. Build tools can generate fallbacks automatically from your tokens.
You can choose the color space used to blend gradients and animations with the in keyword. Blending in OKLCH or OKLab avoids the gray, muddy middle that sRGB gradients show between saturated colors.
The second gradient keeps its brightness and color across the whole bar. For polar spaces such as oklch you can also say which way to go around the hue circle, for example in oklch longer hue.
Relative color syntax lets you derive a color from another one and change only a channel:
The hover color keeps chroma and hue and reduces lightness by 0.1. Relative colors are available in current browsers, but check support tables for your audience before depending on them without a fallback.
For palettes and theming, yes, because lightness is perceptually consistent. HSL is still fine for simple cases and is easier to learn.
Both are perceptual, but OKLab was designed more recently with better hue uniformity, especially for blues and for gradients. Many designers prefer it.
They work in current major browsers. Provide an sRGB fallback if you need to support older versions.
Yes. Colors with high chroma can be outside sRGB, and they display fully only on a wide-gamut screen. Others get mapped to the closest displayable color.
Modern color spaces describe color the way people see it. oklch() gives you lightness, chroma and hue with uniform lightness, so palettes and gradients behave predictably, and it can reach wide-gamut colors beyond sRGB. Use a hex fallback before the oklch() declaration, pick colors by L for contrast, and choose the interpolation space with in oklch when you blend colors.