How to Use OKLCH Colors in CSS (2026)
Why OKLCH beats HSL, measured: fully saturated HSL colors at "50% lightness" differ 12.9-fold in luminance, OKLCH colors at the same L only 1.21-fold. Plus the popular custom-property fallback that does not work, and one that does.
Why OKLCH: Measured
In HSL, "lightness" is arithmetic, not perception. We compared the relative luminance (the quantity WCAG contrast is built on) of fully saturated colors at the same HSL lightness, hsl(h 100% 50%), with colors at the same OKLCH lightness, oklch(0.7 0.15 h), every 10° round the hue circle (coloraide, gamut-mapped to sRGB; October 14, 2026):
| Colors at "the same lightness" | Darkest hue | Brightest hue | Spread |
|---|---|---|---|
| hsl(h 100% 50%) | 0.072 (blue) | 0.928 (yellow) | 12.9× |
| oklch(0.7 0.15 h) | 0.315 | 0.382 | 1.21× |
So HSL's 50% blue and 50% yellow differ almost thirteen-fold in luminance, while every OKLCH hue at L 0.7 lands within about 20% of the others. That is what makes OKLCH useful for palettes: change the hue, keep the lightness, and the contrast stays put.
Syntax
oklch(L C H): L is lightness from 0 to 1 (or 0-100%), C is chroma from 0 (grey) up to about 0.32 for the most saturated sRGB color (magenta), higher for wide-gamut colors, H is the hue angle. Alpha follows a slash: oklch(0.7 0.15 145 / 0.5). Relative color syntax derives new colors from a variable, for example oklch(from var(--brand) l calc(c * 0.5) h) for a muted version.
Practical Uses
- Scales: fix hue and chroma, step L evenly (for example 0.95 down to 0.25), and adjust chroma at the ends where the gamut narrows.
- Theme pairs:
oklch(0.2 0.02 h)text onoklch(0.95 0.02 h)backgrounds measured between 15.61:1 and 15.68:1 for every hue we tried, so one rule works for every brand color. At higher chroma, check again: gamut mapping changes lightness slightly. - Gradients:
linear-gradient(in oklch, …)keeps the middle saturated instead of passing through grey.
Browser Support and a Fallback That Actually Works
MDN's compatibility data lists oklch() in Chrome and Edge 111, Firefox 113 and Safari 15.4. A common fallback snippet repeats a custom property: --brand: #3B82F6; --brand: oklch(0.62 0.2 260);. That does not work. Custom properties are not checked when parsed, so the second declaration always wins, and a browser that cannot read oklch() then finds the property "invalid at computed-value time" where it is used, and falls back to the property's inherited or initial value, not to your hex. Put the fallback on the property that uses the color, or use @supports:
.button {
background: #3B82F6; /* older browsers */
background: oklch(0.62 0.2 260); /* ignored if not understood */
}
@supports (color: oklch(0 0 0)) {
:root { --brand: oklch(0.62 0.2 260); }
}
The Color Converter reads oklch() and every other CSS Color 4 syntax and gives the gamut-mapped sRGB hex for fallbacks.
Frequently Asked Questions
What’s the difference between OKLCH and LCH?
Can I use OKLCH for gradients?
Is OKLCH harder to use than hex?
- [1]W3C, CSS Color Module Level 4: OKLab and OKLCH ↗
- [2]Björn Ottosson, A perceptual color space for image processing (OKLab) ↗
- [3]MDN browser-compat-data, css.types.color.oklch, checked Oct 14, 2026 ↗
- [4]W3C, CSS Custom Properties Level 1: invalid at computed-value time ↗
- [5]coloraide (measurement library) ↗