The color-gamut media feature detects how wide a display’s color range is. Serve richer hues on P3 and Rec. 2020 screens while keeping sRGB-safe fallbacks for standard monitors.
01
@media
Media query.
02
srgb
Standard.
03
p3
Wide gamut.
04
rec2020
Ultra wide.
05
Enhance
Progressive.
06
Fallback
sRGB base.
Fundamentals
Introduction
A color gamut is the range of colors a screen can actually display. The @media color-gamut feature lets you detect which gamut a device supports and apply styles accordingly — from standard sRGB web colors to the vivid Display P3 palette on modern phones and MacBooks.
This is progressive enhancement for color. Start with sRGB-safe designs that look good everywhere, then layer on more saturated colors for displays that can show them.
Definition and Usage
Write @media (color-gamut: srgb), @media (color-gamut: p3), or @media (color-gamut: rec2020). A device that supports P3 also matches srgb, so place wider-gamut rules after your base styles so they override correctly.
💡
Beginner Tip
Think of gamuts as nested circles: sRGB fits inside P3, which fits inside Rec. 2020. Default to sRGB colors; enhance with P3 only when the display supports it.
Both queries may match on P3 devices, but the P3 rule comes last and wins for background and border colors.
Tips
💬 Usage Tips
Progressive enhancement — Default styles should look great in sRGB; P3 is a bonus.
Rule order matters — Place (color-gamut: p3) and rec2020 after base styles.
Use color() function — Pair with color(display-p3 …) to specify out-of-sRGB hues.
Test on real devices — Compare iPhone/Mac (P3) vs standard external monitors (sRGB).
Do not clip colors — Extremely saturated sRGB hex values may look dull; P3 fixes that on capable screens.
Watch Out
⚠️ Common Pitfalls
Wrong rule order — Putting srgb last overrides wider gamut styles on P3 devices.
Assuming everyone sees P3 — Many office monitors are sRGB-only; never depend on wide gamut for readability.
Confusing with color feature — color = has color; color-gamut = how wide the range is.
Over-saturation — P3 colors can look neon; test for comfort and brand consistency.
Accessibility — Vivid colors must still meet contrast requirements on all gamuts.
A11y
♿ Accessibility
Contrast on all gamuts — Verify WCAG contrast ratios for both sRGB and P3 color values.
Do not rely on vivid color alone — Use icons, labels, and patterns alongside color cues.
Test sRGB fallback — Ensure the default palette is fully accessible without P3 enhancement.
Color blindness — Wide-gamut reds and greens can still confuse; test with simulators.
Reduced transparency — P3 backgrounds behind text need sufficient opacity for readability.
🧠 How color-gamut Works
1
Browser queries display
The user agent asks the output device which color gamuts it supports.
Query
2
Gamut level matches
srgb, p3, or rec2020 queries match if the display supports that gamut or wider.
Match
3
Enhanced CSS applies
Later rules with wider gamut colors override sRGB defaults.
Apply
=
🎨
Richer visuals
Wide-gamut displays show more vivid, accurate colors.
Compatibility
🖥 Browser Compatibility
The color-gamut media feature is supported in modern browsers.
✓ Baseline · Modern browsers
Wide-gamut queries in production
Works in Chrome, Firefox, Safari, and Edge.
94%Global support
color-gamut media feature94% supported
Bottom line:color-gamut is safe for progressive color enhancement. Always ship sRGB fallbacks first.
Wrap Up
🎉 Conclusion
The color-gamut media feature unlocks richer, more accurate colors on modern wide-gamut displays. By starting with sRGB-safe defaults and enhancing with p3 and rec2020 rules, you deliver better visuals without leaving standard monitors behind.
Pair gamut queries with the color() function and keep accessibility in mind. Your designs will look great on every screen — and stunning on the ones that support it.
Use these points when enhancing color for wide-gamut displays.
5
Core concepts
RGB01
srgb
Baseline.
Default
P302
p3
Wide gamut.
Enhance
202003
rec2020
Ultra wide.
HDR
↓04
Order
Wide last.
Cascade
🌐05
94% support
Modern browsers.
Compat
❓ Frequently Asked Questions
The color-gamut media feature detects which range of colors a display can reproduce. Use @media (color-gamut: srgb), (color-gamut: p3), or (color-gamut: rec2020) to serve richer colors on wide-gamut screens while keeping sRGB-safe fallbacks everywhere else.
srgb is the standard web color space used by most monitors. p3 (Display P3) is a wider gamut found on many modern phones, tablets, and Mac displays. rec2020 is an even wider gamut used primarily on high-end 4K/8K HDR displays.
Yes. Wider gamuts include narrower ones — a P3 display also matches (color-gamut: srgb). Write base styles for sRGB first, then override with (color-gamut: p3) and (color-gamut: rec2020) rules placed later in your stylesheet.
The color feature checks whether the device can display color at all (monochrome vs color). color-gamut checks how wide the color range is on capable displays — sRGB vs wide-gamut P3 and beyond.
Yes. color-gamut is supported in modern Chrome, Firefox, Safari, and Edge. Use it for progressive enhancement — always provide sRGB-safe defaults that look good on every screen.