Display P3
sRGB
Wide-Gamut CSS
CSS Color 4
Accessibility

Display P3 vs. sRGB in CSS: Wide-Gamut Palettes and Fallbacks

Build from eight measured sRGB tokens, then use a real wide-gamut emerald to see what Display P3 adds without changing your interface controls.

ColorIndicator Academy
6 min read
Published

A cobalt link does not need to change when a screen can render a more saturated emerald. That is the useful starting point for Display P3: let a wider gamut improve the artwork while the link, its hover state and its keyboard focus keep the familiar colors you already tested.

CSS hex, rgb() and hsl() specify sRGB colors. color(display-p3 …) can describe colors beyond that range, but the notation alone does not tell you whether a color is outside sRGB. The two spaces share a D65 white point and transfer curve. Their red and green primaries differ, which changes the range of colors they can describe. See the W3C Display P3 definition.

One green swatch, two color paths

The two chips in this example start with the same sRGB emerald, #047857. Only the second chip can switch to color(display-p3 0.02 0.48 0.34). That green falls outside sRGB: converting it to linear sRGB before any gamut mapping gives a negative red component. The labels and the cobalt action remain the same, so the color difference never carries instructions.

Save the example as an HTML file and open it in a browser. @supports checks the CSS color syntax. @media (color-gamut: p3) checks the approximate range available to the browser and output device, not the exact coverage or calibration of the panel. A browser may map colors into the gamut it can display; the query is not a guarantee of an exact physical match. See the W3C color-gamut media feature.

HTML and CSS: fixed sRGB reference and responsive Display P3 swatch
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Display P3 and sRGB swatch comparison</title>
<style>
  :root {
    --canvas: #FFFFFF;
    --card: #F3F4F6;
    --ink: #111827;
    --action: #1D4ED8;
    --action-hover: #1E40AF;
    --emerald: #047857;
    --emerald-enhanced: var(--emerald);
  }

  @supports (color: color(display-p3 0 0 0)) {
    @media (color-gamut: p3) {
      :root { --emerald-enhanced: color(display-p3 0.02 0.48 0.34); }
    }
  }

  body { background: var(--canvas); color: var(--ink); font: 1rem/1.5 system-ui; }
  main { max-width: 32rem; margin: 2rem auto; padding: 1rem; background: var(--card); }
  .swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .chip { display: block; height: 4rem; border-radius: .5rem; }
  .chip-srgb { background-color: var(--emerald); }
  .chip-p3 { background-color: var(--emerald-enhanced); }
  .action { display: inline-block; padding: .5rem .75rem; background: var(--action); color: var(--canvas); }
  .action:hover { background: var(--action-hover); }
  .action:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
</style>
<main>
  <h1>Emerald on two color paths</h1>
  <div class="swatches">
    <div><span class="chip chip-srgb" aria-hidden="true"></span>sRGB reference</div>
    <div><span class="chip chip-p3" aria-hidden="true"></span>P3 when supported</div>
  </div>
  <p><a class="action" href="#notes">Read the comparison notes</a></p>
  <h2 id="notes">Comparison notes</h2>
  <p>If both swatches match, the second may still be using the sRGB fallback.
    The action uses the same sRGB colors in either case.</p>
</main>
</html>

Eight sRGB starting colors

Use the light card and canvas for the example above. The two dark values are for a separate dark-surface pairing; they are not a dark theme switch in the sample. HEX, RGB and HSL below each describe the same sRGB color, with HSL rounded to whole numbers.

TokenHEXRGBHSL (rounded)Example role
Canvas#FFFFFF255, 255, 2550°, 0%, 100%Light page and action label
Subtle card#F3F4F6243, 244, 246220°, 14%, 96%Light card background
Primary ink#11182717, 24, 39221°, 39%, 11%Light-theme text
Cobalt#1D4ED829, 78, 216224°, 76%, 48%Light-theme action, link and focus outline
Cobalt hover#1E40AF30, 64, 175226°, 71%, 40%Hover surface for the main action
Emerald#0478574, 120, 87163°, 94%, 24%Fixed swatch and sRGB accent
Obsidian#090D169, 13, 22222°, 42%, 6%Dark background
Mint#34D39952, 211, 153158°, 64%, 52%Text or accent on obsidian

Check the actual foreground and background

WCAG AA calls for at least 4.5:1 for normal text and 3:1 for large text, subject to the criterion's exceptions. A control or state also needs 3:1 against adjacent colors when that visual information is needed to identify it. That is why the example checks the outline against the surrounding card, separately from white text against the button. A decorative emerald chip is not a control boundary. See Contrast (Minimum) and Non-text Contrast.

ForegroundBackgroundRatioApplication
#111827#FFFFFF17.74:1AAA normal text on white
#111827#F3F4F616.12:1AAA normal text on the card
#34D399#090D1610.11:1AAA normal mint text on obsidian
#FFFFFF#1E40AF8.72:1AAA normal text on the hover fill
#FFFFFF#1D4ED86.70:1AA normal text on the action; same ratio for a cobalt link on white
#1D4ED8#F3F4F66.09:1AA normal link text; above 3:1 for the outline against the card
#047857#FFFFFF5.48:1AA normal emerald text on white
#047857#F3F4F64.98:1AA normal emerald text on the card
#34D399#FFFFFF1.92:1Fails AA for text, including large text

Use the Contrast Checker for these sRGB pairs. If you add P3 to a functional token, audit the new pair for each state and theme, and check the result on target devices. The image analyzer can suggest HEX values from an image; an extracted HEX is not a way to recover the original CSS token or verify Display P3 contrast.

Frequently asked questions

What does Display P3 add compared with sRGB?

Display P3 can describe colors outside the sRGB gamut, including the enhanced emerald in this example. It shares the D65 white point and transfer curve of sRGB, but uses different red and green primaries. It is a color space, not an HDR mode.

Do I still need an sRGB fallback for Display P3?

Yes. Start with an sRGB value, then add the optional P3 value behind a CSS syntax check and a color-gamut media query. On the fallback path, the same interface should remain readable and usable.

Does passing sRGB contrast validate a Display P3 override?

No. The measured contrast applies to the specified sRGB pair. If a P3 override changes text, its background, or a required visual cue, verify that actual pair separately and check the result on target devices.

Sources

Related reading

Continue exploring this color story

New Palette Library

Explore 120 curated color palettes

Website, SaaS, brand, minimal, dark, pastel, and seasonal palettes ready for design work.

Open Palettes