CSS color-gamut Media Feature

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 4 Examples
Media Queries

What You’ll Learn

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.

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.

📝 Syntax

Target specific color gamuts inside @media rules:

syntax.css
@media (color-gamut: srgb) {
  /* Standard RGB gamut (most displays) */
}

@media (color-gamut: p3) {
  /* Display P3 — wider than sRGB */
}

@media (color-gamut: rec2020) {
  /* Rec. 2020 — widest gamut (HDR/4K) */
}

Accepted Values

  • srgb — Standard RGB color space. Supported by virtually all color displays; the default web palette.
  • p3 — Display P3, a wider gamut common on iPhones, iPads, and many modern Mac and Android screens.
  • rec2020 — ITU-R Rec. 2020, the widest gamut; found on high-end HDR and 4K/8K displays.

Gamut Comparison

srgb Standard web colors. Safe baseline for all devices.
p3 More vivid greens, reds, and blues than sRGB.
rec2020 Widest range; HDR and premium displays.

Basic Example

color-gamut-basic.css
/* sRGB-safe default */
body {
  background-color: #2563eb;
}

/* Enhance on P3 displays */
@media (color-gamut: p3) {
  body {
    background-color: color(display-p3 0.1 0.55 1);
  }
}

/* Further enhance on Rec. 2020 */
@media (color-gamut: rec2020) {
  body {
    background-color: color(rec2020 0.2 0.7 0.95);
  }
}

Default Value

There is no CSS default. The browser reports the display’s gamut capability at runtime.

Syntax Rules

  • Only three values are valid: srgb, p3, and rec2020.
  • Wider gamuts match narrower ones — order rules from sRGB base to widest enhancement.
  • Pair with color(display-p3 …) or color(rec2020 …) for out-of-sRGB hues.
  • Always provide sRGB fallbacks that look good without wide-gamut colors.
  • Distinct from color media feature (monochrome vs color capability).

Related Topics

@media (color-gamut: p3) @media (color-gamut: srgb) @media (color-gamut: rec2020)

⚡ Quick Reference

QuestionAnswer
Feature namecolor-gamut
Valuessrgb, p3, rec2020
What it detectsDisplay color range (gamut width)
Most common wide gamutp3 (Display P3)
Rule ordersRGB base first, wider gamuts override later
Browser supportModern Chrome, Firefox, Safari, Edge

When to Use color-gamut

Use color-gamut when display color range affects visual quality:

  • Brand colors — Show more vivid brand hues on P3 displays without clipping on sRGB.
  • Photography & art — Serve richer gradients and images on wide-gamut screens.
  • Marketing heroes — Enhance hero section backgrounds on capable hardware.
  • UI accents — Use saturated accent colors where displays can render them accurately.
  • HDR content — Target rec2020 for premium display experiences.

👀 Live Preview

This box uses sRGB blue by default. On Display P3 screens it shifts to a more vivid green; on Rec. 2020 displays it becomes a deep orange-red:

Wide-Gamut Demo Enhanced by color-gamut media queries

Examples Gallery

Practice color-gamut with progressive backgrounds, P3 gradients, hero sections, and sRGB fallbacks.

📜 Core Patterns

Layer richer colors on displays with wider gamuts.

Example 1 — Progressive background by gamut

Start with sRGB blue, enhance to P3 green, then Rec. 2020 red — wider rules placed last:

color-gamut-background.css
body {
  background-color: #3333ff;
  font-family: system-ui, sans-serif;
  padding: 2rem;
}

@media (color-gamut: p3) {
  body {
    background-color: color(display-p3 0.2 1 0.35);
  }
}

@media (color-gamut: rec2020) {
  body {
    background-color: color(rec2020 1 0.35 0.2);
  }
}
Try It Yourself

How It Works

Every device gets the sRGB default. P3 and Rec. 2020 rules override only when those gamuts are supported.

Example 2 — Vivid P3 gradient

Replace a flat sRGB gradient with a richer Display P3 version on capable screens:

color-gamut-gradient.css
.banner {
  padding: 2rem;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
}

@media (color-gamut: p3) {
  .banner {
    background: linear-gradient(
      135deg,
      color(display-p3 0.55 0.1 1),
      color(display-p3 0.05 0.45 1)
    );
  }
}
Try It Yourself

How It Works

The sRGB gradient is the fallback. P3 color() functions unlock more saturated purple and blue on wide-gamut hardware.

Example 3 — Hero accent color on P3

Enhance a call-to-action button with a more saturated brand color on Display P3:

color-gamut-hero.css
.cta {
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 0.4rem;
  background: #dc2626;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

@media (color-gamut: p3) {
  .cta {
    background: color(display-p3 1 0.15 0.1);
  }
}
Try It Yourself

How It Works

sRGB red is safe everywhere. Display P3 red is more vivid on screens that can render it without clipping.

Example 4 — Explicit sRGB fallback pattern

Use (color-gamut: srgb) to scope safe styles and enhance only outside that block:

color-gamut-fallback.css
.card {
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
}

@media (color-gamut: srgb) {
  .card {
    background: #eff6ff;
    border-color: #93c5fd;
  }
}

@media (color-gamut: p3) {
  .card {
    background: color(display-p3 0.85 0.95 1);
    border-color: color(display-p3 0.35 0.65 1);
  }
}
Try It Yourself

How It Works

Both queries may match on P3 devices, but the P3 rule comes last and wins for background and border colors.

💬 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.

⚠️ 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 featurecolor = 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.

♿ 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.

🖥 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 feature 94% supported

Bottom line: color-gamut is safe for progressive color enhancement. Always ship sRGB fallbacks first.

🎉 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.

💡 Best Practices

✅ Do

  • Default to sRGB-safe colors
  • Place wider gamut rules last
  • Use color(display-p3 …) for P3
  • Test on P3 and sRGB screens
  • Check contrast on all gamuts

❌ Don’t

  • Put srgb rules after p3 rules
  • Require P3 for readability
  • Confuse color vs color-gamut
  • Over-saturate without testing
  • Skip sRGB fallbacks

Key Takeaways

Knowledge Unlocked

Five things to remember about color-gamut

Use these points when enhancing color for wide-gamut displays.

5
Core concepts
P3 02

p3

Wide gamut.

Enhance
2020 03

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.

Practice in the Live Editor

Open the HTML editor and experiment with @media (color-gamut: p3) and Display P3 color functions.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful