Modern CSS Color in 2026: OKLCH, P3, and What You Can Ship
CSS color has gained several useful features in the last few years. OKLCH gives you a more even way to adjust lightness and chroma. Display P3 lets you express colors outside sRGB. color-mix() derives shades and tints in the stylesheet. Relative color syntax builds new colors from an existing one.
This post covers what each feature does and when browsers added it, so you can decide what needs a fallback.
The mental model: sRGB is the world; everything else is bigger
For the last 25 years of the web, "a color" meant a triplet in the sRGB color space. #facc15 is an sRGB value. rgb(250, 204, 21) is the same value with explicit syntax. hsl() is the same gamut with hue/saturation/lightness coordinates instead.
sRGB was defined in 1996 around typical CRT monitors. It covers roughly 36% of the CIE 1931 chromaticity diagram. Display P3, which many modern phones and laptops can show, covers roughly 45%. The new CSS color formats let you reach beyond sRGB on those displays.
You can think of the new color formats in two buckets:
- Coordinate systems that are not tied to a display: OKLCH, OKLAB, and the older CIE-based
lab()andlch(). These can describe any visible color, including colors outside sRGB. - Named wider color spaces, reached through
color():display-p3,rec2020,a98-rgb,prophoto-rgb.
OKLCH
OKLCH expresses a color as lightness, chroma, and hue. In HSL, 50% lightness on yellow looks much brighter than 50% lightness on blue. OKLCH's lightness is designed to track perceived lightness, so oklch(70% 0.15 240) and oklch(70% 0.15 30) look close in brightness.
This makes design tokens easier to reason about: the same lightness and chroma recipe gives similar visual weight across hues. It does not guarantee equal WCAG contrast, which uses a different formula. For example, against white, oklch(70% 0.15 240) scores about 2.63:1 and oklch(70% 0.15 30) about 2.85:1. They are close to each other, but both fail 4.5:1 for text, so you still have to check them.
:root {
--primary: oklch(70% 0.15 240); /* blue */
--secondary: oklch(70% 0.15 30); /* red, same perceived weight */
--primary-hover: oklch(65% 0.15 240); /* darker, same hue */
--primary-bg: oklch(95% 0.05 240); /* tint */
}
Browser support: Chrome 111, Safari 15.4, and Firefox 113, all from 2023 or earlier. High chroma values can fall outside sRGB, in which case the browser maps them to the nearest color it can show. An OKLCH value may therefore look different on a P3 display than on an sRGB one.
Display P3
Display P3 is a wider color space. color(display-p3 1 0 0) is a more saturated red than #ff0000 on a P3 screen. On an sRGB-only display, the browser maps it to the nearest color it can show, which looks like plain #ff0000.
P3 suits vibrant brand accents. It adds little for body text or backgrounds, and it makes colors less consistent across displays.
.brand-accent {
/* Fallback for browsers without color() */
color: #ff3366;
}
@media (color-gamut: p3) {
.brand-accent {
color: color(display-p3 1 0.2 0.4);
}
}
color-mix()
color-mix() blends two colors in a given color space. A common use is deriving hover, disabled, and tint colors from one base color:
:root {
--primary: oklch(70% 0.15 240);
}
.btn-primary {
background: var(--primary);
}
.btn-primary:hover {
/* Mix in 12% black */
background: color-mix(in oklch, var(--primary), black 12%);
}
.btn-primary:disabled {
/* Mix in 60% gray */
background: color-mix(in oklch, var(--primary), gray 60%);
}
.btn-primary-bg {
/* 90% white, for light backgrounds */
background: color-mix(in oklch, var(--primary), white 90%);
}
The color space changes the result. Mixing in sRGB can produce dull midpoints when two colors are far apart in hue. Mixing in OKLCH keeps chroma up but travels around the hue wheel, so a mix of red and green passes through orange and yellow. Mixing in oklab goes straight between the two colors without that hue rotation.
Browser support: Chrome 111, Safari 16.2, and Firefox 113. Baseline since 2023.
Relative color syntax
Relative color syntax lets you express a color in terms of another color and a transformation:
:root {
--primary: oklch(70% 0.15 240);
--primary-dark: oklch(from var(--primary) calc(l - 0.1) c h);
--primary-muted: oklch(from var(--primary) l calc(c * 0.3) h);
}
This is more precise than color-mix() when you need to change one channel, such as "same hue, 30% of the chroma". It is also harder to read.
Browser support: Chrome 119, Safari 16.4, and Firefox 128 (July 2024). Some details, such as currentcolor as the origin color, arrived later, so test those cases. For theme colors that must not break, add a plain fallback declaration before it.
What about gradients?
A gradient using legacy color formats interpolates in sRGB by default, which can pass through a dull midpoint, as red to green does. If any color in the gradient uses a modern syntax such as oklch(), the default is Oklab instead.
You can set the interpolation space explicitly:
/* Default for legacy colors: sRGB */
background: linear-gradient(to right, red, green);
/* Explicit interpolation space */
background: linear-gradient(in oklch to right, red, green);
The same syntax applies to radial and conic gradients. Browser support: Chrome 111, Safari 16.2, and Firefox 127.
Accessibility implications
The WCAG 2 contrast formula is defined for sRGB. A P3 or OKLCH color has to be converted before it can be scored, and a color outside sRGB has no exact sRGB equivalent, so tools may disagree slightly. A wider gamut does not earn a better score just by looking more vivid.
OKLCH still helps here: colors with a shared lightness give similar results across hues, so a token scale that fixes lightness tends to behave predictably. Check the final values anyway, as the numbers above show.
The contrast checker on this site takes hex colors, so convert OKLCH values first. The color palette tool generates palettes using HSL.
What needs a fallback
Generally safe without a fallback, if you do not support browsers older than 2023: OKLCH, color-mix(), and gradient interpolation hints.
Add a fallback: relative color syntax, for anything more important than decoration, and P3 colors that carry brand meaning.
Usually unnecessary: lab() and lch() work, but OKLab and OKLCH generally give more even hue behavior.
Rarely useful in ordinary web pages: rec2020 and prophoto-rgb, whose gamuts extend beyond what typical displays can show.
Practical migration path
- Convert your design tokens from hex to OKLCH. The color picker in browser DevTools can show a color in OKLCH; Chrome lists it in the format switcher.
- Replace hover/active state recipes with
color-mix(in oklch, ...). - Add
in oklchto your gradients. - Optionally, add P3 versions of your one or two brand accent colors with sRGB fallback.
- Re-run contrast checks against your new palette.