CSS color-gamut Media Feature

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The color-gamut media feature matches the approximate range of colors the user agent and output device can support. Use it inside @media to serve richer accents on wide-gamut screens while keeping sRGB-safe defaults everywhere else.

The keywords are srgb, p3, and rec2020. Wider gamuts include narrower ones — a P3 display also matches srgb. This is different from the color feature, which reports bits per component.

Baseline widely available.

Supported across modern browsers. Use it for progressive enhancement — always write sRGB-safe base styles first.

CSS Syntax

syntax.css
@media (color-gamut: srgb | p3 | rec2020) { … }

Example: @media (color-gamut: p3) { … }.

Feature Values

ValueDescriptionTry it
srgbApproximately the sRGB gamut or more (most color displays)Try it
p3Approximately Display P3 or more (includes sRGB)Try it
rec2020Approximately Rec. 2020 or more (includes P3)Try it
Stacking orderWrite srgb base, then p3, then rec2020 overridesTry it

How to Use color-gamut

Design for sRGB first, then layer wider gamuts as enhancements.

  1. Set colors that look good in sRGB (your default stylesheet).
  2. Add @media (color-gamut: srgb) only if you need an explicit sRGB branch.
  3. Override with (color-gamut: p3) for Display P3–capable screens.
  4. Optionally add (color-gamut: rec2020) last for the widest displays.
PieceRequired?Role
sRGB base stylesYesSafe on nearly every color screen
@media (color-gamut: …)For enhancementUnlocks wider accents when available
Cascade orderImportantLater, wider queries must win over earlier ones
color featureOptionalChecks bit depth, not gamut width

Live Preview

This page checks your browser with matchMedia for each gamut keyword. The sample box uses real @media (color-gamut) rules.

Device checks

A P3 screen typically matches both srgb and p3. Rec. 2020 matches are rarer.

Results
  • srgb: …
  • p3: …
  • rec2020: …

Sample accent color from stacked gamut queries.

Checking…

CSS Examples

Each snippet focuses on color-gamut. On your machine, only matching queries apply. Use Try It Yourself for a live editor.

Example 1 — srgb

Apply a style when the display supports approximately the sRGB gamut or more.

CSS
<style>
  p {
    padding: 8px;
    border: 1px solid #334155;
    background: #fff;
  }

  @media (color-gamut: srgb) {
    p {
      background: #f4ae8a;
    }
  }
</style>

<p>Peach background on sRGB-or-better screens.</p>
Try It Yourself

How It Works

  1. Set a plain base. White background works without the query.
  2. Query srgb. Matches the vast majority of color displays.
  3. Enhance inside the block. The peach fill only applies when the query matches.
  4. Remember inclusion. P3 and Rec. 2020 screens also match srgb.

Example 2 — p3

Use a richer accent when Display P3 (or wider) is available.

CSS
<style>
  p {
    color: #b91c1c;
    font-weight: 700;
  }

  @media (color-gamut: p3) {
    p {
      color: color(display-p3 1 0.2 0.1);
    }
  }
</style>

<p>Richer red on P3-capable displays.</p>
Try It Yourself

How It Works

  1. Keep an sRGB fallback. Hex #b91c1c works everywhere.
  2. Query p3. Matches Display P3 or wider.
  3. Optional wide color. color(display-p3 …) can express colors outside sRGB when supported.
  4. If P3 does not match, you still see the hex red — progressive enhancement.

Example 3 — Stacked Queries

Layer srgb, then p3, then rec2020 so the widest match wins.

CSS
<style>
  p {
    padding: 8px;
    background: #e2e8f0;
  }

  @media (color-gamut: srgb) {
    p { background: #93c5fd; }
  }

  @media (color-gamut: p3) {
    p { background: #60a5fa; }
  }

  @media (color-gamut: rec2020) {
    p { background: #2563eb; }
  }
</style>

<p>Background steps up with wider gamut.</p>
Try It Yourself

How It Works

  1. Start neutral. Gray is the no-match fallback.
  2. Match srgb first. Most screens pick up the light blue.
  3. Override with p3. Wider screens get a stronger blue because this rule comes later.
  4. Finish with rec2020. Only the widest displays take the deepest blue.

Edge Cases & Pitfalls

Most issues come from cascade order or treating gamut as bit depth.

inclusion

Wider includes narrower

A P3 display matches both srgb and p3. Put the wider query after the narrower one so it can override.

vs color

Not the same as color

color is bits per channel. color-gamut is how wide the color range is. You often use both for different questions.

fallback

Always keep sRGB defaults

Never rely only on P3 or Rec. 2020 colors. Base styles must remain readable on standard monitors.

approx

Approximate match

The feature is approximate (“about this gamut or more”). Do not treat it as a precise color-management certificate.

Browser Support

color-gamut is a browser CSS media feature. Node.js, Deno, and Bun do not evaluate it.

✓ Baseline · Widely available

color-gamut

Supported in modern Chrome, Firefox, Safari, and Edge. Use progressive enhancement with sRGB base styles.

95% Modern browsers
Google Chrome Supported
Full support
Mozilla Firefox Supported
Full support
Apple Safari Supported
Full support
Microsoft Edge Supported
Full support
Opera Supported
Full support
Samsung Internet Supported
Full support
Internet Explorer No
No support
@media (color-gamut) Baseline · Widely available

Bottom line: Safe for progressive wide-gamut styling. Always ship sRGB-safe defaults. This is not a JavaScript runtime API.

Key Takeaways

  • Role: match approximate display gamut — srgb, p3, or rec2020.
  • Inclusion: wider queries also match narrower keywords.
  • Cascade: write sRGB → P3 → Rec. 2020 so the widest wins.
  • Enhance only: never drop sRGB-safe defaults.

One line: color-gamut lets capable screens go wider — start in sRGB, then step up to P3 and Rec. 2020.

Frequently Asked Questions

It matches approximately how wide a color range the user agent and output device can support — roughly sRGB, Display P3, or Rec. 2020 — so you can enhance colors on capable screens.
srgb is the common web color space. p3 (Display P3) is wider and includes sRGB. rec2020 is wider still and includes P3, mostly on high-end HDR displays.
Yes. Wider gamuts include narrower ones. A P3 display also matches (color-gamut: srgb). Put base sRGB styles first, then override with p3 and rec2020 rules later.
The color feature reports bits per RGB component (color vs monochrome depth). color-gamut reports how wide the reproducible color range is on a color display.
No. Always provide sRGB-safe defaults. Treat p3 and rec2020 as progressive enhancement so every screen stays readable.
Yes. It is Baseline Widely available. It is a browser CSS media feature, not a Node.js API.

Next: color-index

Learn how to query indexed-color palette size with media features.

color-index tutorial →

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