Search tools

Color guides

Display P3 vs sRGB in CSS: Safe Hex Fallbacks for OKLCH Colors

High-chroma OKLCH colors clip silently or fail inside CSS variables on standard displays. Learn how Display P3 limits work and ship safe sRGB hex fallbacks.

3D luminous emerald and cyan optical glass ring surrounding an inner hexagonal teal crystal lens on a dark charcoal studio backdrop

Writing vivid oklch() values in CSS gives you Display P3 greens, cyans, and reds that hex codes simply cannot represent. Left unchecked, though, wide-gamut tokens either clip awkwardly on sRGB monitors or break your CSS variables completely in older browsers.

Here is the safe rule: check whether each oklch() token sits inside sRGB or Display P3, map out-of-gamut colors down in chroma at constant hue to find an sRGB #RRGGBB fallback, and guard CSS variable overrides with @supports (color: oklch(0% 0 0)).

You can check P3 boundaries and generate exact @supports fallbacks for any hex or oklch() string with our Hex to OKLCH converter.

Why do some oklch() values exceed #RRGGBB hex limits?

Unlike #RRGGBB hex, OKLCH describes color with an unbounded Chroma (C) coordinate. Standard sRGB screens can only display chroma up to roughly 0.20 to 0.32 depending on hue and lightness, whereas Display P3 reaches much higher saturation.

Take oklch(72% 0.29 145). At 72% lightness and hue 145 degrees (bright emerald green):

  • sRGB chroma ceiling: 0.22645
  • Display P3 chroma ceiling: 0.30729
  • Target chroma (0.29): Valid on Display P3 panels, yet outside sRGB gamut

display-p3-vs-srgb-hex-fallback-oklch-diagram

A standard sRGB monitor cannot physically emit green at C = 0.29. Your browser must gamut-map that pixel back toward #00C737 (oklch(72% 0.22645 145)), trimming chroma without shifting the hue angle.

Color Token Chroma C Fits sRGB? Fits Display P3? Faithful sRGB Hex
oklch(51.06% 0.23005 276.97) 0.23005 Yes Yes #4F46E5
oklch(72.27% 0.19201 149.58) 0.19201 Yes Yes #22C55E
oklch(72% 0.29 145) 0.29000 No Yes #00C737
oklch(68% 0.26 25) 0.26000 No Yes #FF5352

Why CSS custom properties still need @supports for OKLCH

On a plain CSS property, progressive enhancement relies on the cascade. Older browsers skip the second line automatically when they don’t parse oklch():

.badge {
  background-color: #00c737;
  background-color: oklch(72% 0.29 145);
}

CSS custom properties follow a different rule. Browsers accept virtually any token sequence inside --brand: oklch(...) during parsing, even if the engine cannot understand oklch(). When var(--brand) later resolves on an element, it becomes invalid at computed-value time (IACVT) and resets to initial or transparent instead of falling back to #00c737.

Wrap every OKLCH custom property override inside @supports so legacy browsers keep your hex value intact:

:root {
  --color-brand: #00c737;
}

@supports (color: oklch(0% 0 0)) {
  :root {
    --color-brand: oklch(72% 0.29 145);
  }
}

How to upgrade Tailwind tokens safely to wide gamut

Tailwind CSS v4 stores its default @theme colors as decimal OKLCH tokens inside sRGB bounds so builds look predictable everywhere. When you intentionally push brand accents into Display P3, inspect contrast ratios against both surfaces before shipping.

Clipping from Display P3 down to #00C737 drops visual punch, which can slightly alter perceived weight on buttons. Our article on why OKLCH beats HSL for lightness explains why holding Lightness (L) constant keeps button labels readable even when chroma gets clipped.

For progressive teams wanting both worlds:

  1. Keep surface, text, and border tokens inside sRGB so WCAG contrast numbers stay identical across all screens.
  2. Reserve Display P3 chromas for brand badges, focus highlights, and active charts.
  3. Map every wide-gamut token cleanly down at constant L and H rather than letting naive RGB channel clamping shift hues yellow or cyan.

Display P3 and OKLCH FAQ

Does Display P3 break dark text contrast ratios?

Usually only slightly, though you should test both values. Higher P3 chroma adds brightness on OLED screens while slightly changing relative luminance after clamping to sRGB hex. Check your sRGB fallback hex directly against button text to verify WCAG AA compliance.

How can I preview Display P3 colors on an sRGB monitor?

You can’t physically view P3-only saturation on a standard sRGB panel because the backlight lacks wider primaries. However, Chrome and Firefox DevTools show exact gamut boundary lines in the Color Picker so you see where clipping starts.

Should every hex token move to Display P3?

No. Most interface design systems work best inside sRGB, using oklch() strictly for uniform perceptual lightness steps rather than extreme saturation.

Check whether your hex or oklch() values stay inside sRGB or push into Display P3 using the Hex to OKLCH converter.

Read next