Course contentsShow
← Web Development
Lesson 499 of 2,9828. Advanced CSS Selectors and FeaturesFree lesson

Gamut Mapping and Out-of-Gamut Colors

Understand how browsers handle colors outside a display's gamut and techniques to preserve color intent across devices.

Gamut Mapping and Out-of-Gamut Colors

You'll learn how browsers handle colors that displays can't physically show, and how to maintain your design's color intent across different devices.

What Are Out-of-Gamut Colors?

Not every color you specify in CSS can actually be displayed on every screen. When you use modern color spaces like Display-P3, OKLCH, or LAB, you might choose colors that are "out-of-gamut" for a particular display—meaning that display physically cannot produce those exact colors.

Think of it like asking a printer to print a color that's not in its ink cartridge. The printer has to make a "best guess" replacement.

How Browsers Handle the Gap

When you specify an out-of-gamut color, browsers perform gamut mapping—automatically converting that color to the closest displayable alternative. This process tries to preserve the color's intent (like keeping it vibrant or maintaining relative brightness) while fitting it within the display's capabilities.

For example, if you specify a vivid cyan in Display-P3 on an sRGB-only monitor, the browser maps it to the most similar cyan that sRGB can produce.

.vibrant-box {
  /* May be out-of-gamut on some displays */
  background-color: oklch(75% 0.25 180);
}

Why It Matters

Different devices have different gamuts. A high-end phone might display your brilliant Display-P3 colors perfectly, while an older laptop reduces them to sRGB. Your design won't break—browsers handle this automatically—but colors may appear less vibrant on limited displays. Understanding this helps you test across devices and set realistic expectations about color fidelity.

Key Takeaway: Browsers automatically map out-of-gamut colors to the closest displayable alternative, preserving your design intent across devices with different color capabilities, so your specified colors gracefully degrade rather than breaking.