rgb(), hex and hsl() all describe sRGB, the gamut of the old web. hsl() only reshapes the RGB cube into hue, saturation and lightness; its lightness is arithmetic, not perceptual. hsl(60 100% 50%) (yellow) and hsl(240 100% 50%) (blue) share 50% but have Oklab lightness 0.97 and 0.45.
CSS Color 4 adds colour spaces built for people and for modern screens:
oklch(L C H)is the polar form of Oklab, a space fitted to how people judge colour differences.L(0–1 or 0–100%) is perceived lightness,Cis chroma (0 is grey; in practice it stays under 0.5),His hue in degrees. ChangeHat fixedLandCand you get a new hue at the same visual weight, which is why design systems build palettes and state ramps in it.- Wide gamuts.
color(display-p3 1 0 0)names a red more saturated than any sRGB colour, visible on a P3 screen.oklch()isn't tied to any gamut, so one notation covers sRGB, P3 and beyond.
The catch is gamut mapping. An oklch() value can be outside what the screen shows. The value is kept as written through computed value (getComputedStyle returns oklch(0.7 0.4 30) unchanged); only painting must bring it into range. Color 4 describes reducing chroma at constant lightness and hue. Chrome 156 and Firefox 159 clipped each channel instead when painting to sRGB, so very different out-of-gamut colours can land on the same pixel.
In practice: write colours in oklch(), keep chroma within the target gamut for important colours, and gate vivid P3 values with @media (color-gamut: p3). oklch() shipped in Chrome 111, Firefox 113 and Safari 15.4.