Explore color-mix(), oklch(), oklab(), wide gamut colors, gamut mapping, and gradient interpolation
color-mix(in <color-space>, <color1> <p1>, <color2> <p2>) mixes two colors in a given color space. The color space affects the interpolation path.
oklch(L C H) — Lightness (0-1), Chroma (0-0.4), Hue (0-360). Unlike HSL, equal lightness values produce visually equal brightness across all hues.
oklab(L a b) — Lightness (0-1), a-axis green-red (-0.4 to 0.4), b-axis blue-yellow (-0.4 to 0.4). The Cartesian counterpart of oklch.
The color() function allows specifying colors in wide gamut color spaces like display-p3 and rec2020. These spaces contain colors that sRGB cannot represent.
When a color is outside a display's gamut, the browser must map it to the closest representable color. This process is called gamut mapping. Different strategies produce different results.
Out-of-gamut P3 colors mapped to sRGBDifferent color spaces have different gamuts (ranges of representable colors). Here's how they compare.
Gamut Size ComparisonCSS gradients can interpolate in different color spaces using in <color-space>. This dramatically affects the visual result, especially for complementary colors.
For polar color spaces (oklch, hsl, hwb, lch), you can control the hue interpolation direction: shorter, longer, increasing, decreasing.