CSS color Media Feature

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

What You’ll Learn

The color media feature detects whether a device can display color. Adapt styles for full-color screens vs monochrome displays, and distinguish the media feature from the CSS color property.

01

@media

Media query.

02

(color)

Has color.

03

not

Monochrome.

04

min-color

Bit depth.

05

vs property

Device vs text.

06

A11y

Not color-only.

Introduction

The @media color feature in CSS checks whether the output device can display color. It is used inside media queries to apply different styles depending on display capability — from full-color monitors and phones to grayscale e-readers or monochrome terminals.

While nearly every modern screen matches (color), this feature is still valuable for progressive enhancement, print stylesheets, and providing accessible fallbacks when color cannot convey meaning alone.

Definition and Usage

Write @media (color) for color-capable devices and @media not (color) for devices without color support. You can also use min-color and max-color with a numeric bit depth per color component.

💡
Beginner Tip

Do not confuse this with the CSS color property, which sets text color. The media feature asks: “Can this device show color?”

📝 Syntax

The basic forms of the color media feature are:

syntax.css
@media (color) {
  /* Color-capable devices */
}

@media not (color) {
  /* Monochrome or grayscale devices */
}

@media (min-color: 8) {
  /* 8+ bits per color component (true color) */
}

Feature Variants

  • (color) — Matches when the device supports color (equivalent to min-color: 1).
  • not (color) — Matches monochrome devices with zero color bits.
  • min-color — Matches when the device has at least N bits per color component.
  • max-color — Matches when the device has at most N bits per color component.

Basic Example

color-basic.css
@media (color) {
  body {
    background-color: #dbeafe;
  }
}

@media not (color) {
  body {
    background-color: #e2e8f0;
  }
}

Media Feature vs CSS Property

@media (color) Checks whether the device can display color. Used for conditional layout and fallback styles.
color: #2563eb; Sets an element’s foreground (text) color. Applies regardless of device capability.

Default Value

There is no default value. Styles outside media queries apply universally unless a matching query overrides them.

Syntax Rules

  • (color) is a boolean feature — no value after the colon is needed.
  • Use not (color) for monochrome fallbacks, not (color: 0).
  • Bit-depth queries use integers: (min-color: 8).
  • Combine with other features: @media (color) and (min-width: 48rem).
  • Never rely on color alone to convey information — add icons, labels, or patterns.

Related Topics

@media (color) @media not (color) @media (min-color: 8)

⚡ Quick Reference

QuestionAnswer
Feature namecolor, min-color, max-color
Boolean form(color) or not (color)
What it detectsDevice color display capability (bits per component)
Modern screensAlmost all match (color)
Monochrome fallback@media not (color)
Browser supportAll modern browsers

When to Use color

Use the color media feature when display capability affects design:

  • Monochrome fallbacks — Simplify UI on e-readers or grayscale displays with not (color).
  • Rich gradients — Enable colorful backgrounds on (min-color: 8) true-color screens.
  • Progressive enhancement — Layer color cues on top of shape and text that work everywhere.
  • Print styles — Pair with print media types for black-and-white output.
  • Status indicators — Add color on capable devices; use icons or labels as the primary signal.

👀 Live Preview

On color-capable devices (including yours), this box shows a gradient background. On monochrome devices it would appear flat gray:

Color Capability Demo Detected by @media (color)

Examples Gallery

Practice the color media feature with backgrounds, status badges, gradients, and property comparisons.

📜 Core Patterns

Apply styles based on device color display capability.

Example 1 — Background on color vs monochrome

Apply a blue background on color devices and gray on monochrome displays:

color-background.css
@media (color) {
  body {
    background-color: #dbeafe;
  }
}

@media not (color) {
  body {
    background-color: #e2e8f0;
  }
}
Try It Yourself

How It Works

Color screens get the blue tint; monochrome devices receive a neutral gray fallback.

Example 2 — Accessible status badges

Use color on capable devices but keep icons and text labels as the primary indicator:

color-status.css
.badge {
  padding: 0.35rem 0.65rem;
  border: 1px solid #334155;
  border-radius: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

@media (color) {
  .badge--success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #86efac;
  }
  .badge--error {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
  }
}

@media not (color) {
  .badge {
    background: #f8fafc;
    color: #1e293b;
  }
}
Try It Yourself

How It Works

Icons and words (“Success”, “Error”) remain readable on all devices; color enhances the message on capable screens.

Example 3 — Rich gradient with min-color

Enable a colorful gradient header only on true-color displays with 8 or more bits per component:

color-min-color.css
.header {
  padding: 2rem;
  background: #334155;
  color: #fff;
  text-align: center;
}

@media (min-color: 8) {
  .header {
    background: linear-gradient(135deg, #7c3aed, #2563eb, #06b6d4);
  }
}
Try It Yourself

How It Works

Low-color devices keep a solid fallback; true-color screens get the full gradient treatment.

Example 4 — Media feature vs color property

The media feature gates styles by device; the property always sets element text color:

color-feature-vs-property.css
/* Device capability check */
@media (color) {
  .alert {
    border-left: 4px solid #2563eb;
  }
}

/* Element text color — always applies */
.alert {
  color: #1e293b;
  padding: 0.75rem 1rem;
  background: #f8fafc;
}

@media not (color) {
  .alert {
    border-left: 4px solid #000;
  }
}
Try It Yourself

How It Works

The media query adds a colored accent border on color devices; the color property sets readable text on every device.

💬 Usage Tips

  • Progressive enhancement — Design for monochrome first, then add color with (color).
  • Pair with icons — Never use color as the only way to communicate status or errors.
  • min-color for gradients — Reserve complex gradients for (min-color: 8) displays.
  • Print styles — Combine with @media print for black-and-white output.
  • Name collision — Remember: media color = device; property color = text.

⚠️ Common Pitfalls

  • Assuming not (color) is common — Almost all modern browsers and devices match (color).
  • Color-only meaning — Red/green status colors fail for color-blind users; add icons and labels.
  • Confusing with color property — They share a name but serve different purposes.
  • Replacing contrast checks(color) does not guarantee sufficient contrast; test WCAG ratios.
  • Overusing bit-depth queriesmin-color: 8 matches virtually all current hardware.

♿ Accessibility

  • Do not rely on color alone — WCAG requires a non-color way to convey information.
  • Monochrome fallbacks — Use not (color) to ensure borders, icons, and labels remain clear.
  • Color blindness — Test with simulators; red/green pairs are especially problematic.
  • Sufficient contrast — Colorful badges must still meet contrast requirements on all backgrounds.
  • High contrast mode — Users may override colors; layouts must remain usable.

🧠 How color Works

1

Browser queries device

The user agent asks the output device how many bits of color it supports per component.

Query
2

Feature matches or not

(color) matches if bits ≥ 1. not (color) matches if bits = 0.

Match
3

Conditional CSS applies

Styles inside matching @media blocks update colors, borders, and backgrounds.

Apply
=

Device-appropriate design

Colorful on capable screens; readable everywhere else.

🖥 Browser Compatibility

The color media feature and its min- / max- variants are supported in all modern browsers.

Baseline · Universal support

Color capability queries

Works in Chrome, Firefox, Safari, Edge, and Opera.

99% Global support
color media feature 99% supported

Bottom line: (color) is safe for progressive enhancement. Always provide non-color cues for accessibility.

🎉 Conclusion

The color media feature lets you tailor styles to a device’s color display capability. Use (color) to enhance designs with rich hues and not (color) to provide clean monochrome fallbacks for e-readers and specialized displays.

Remember the naming distinction: the media feature detects device capability; the color property sets element text color. Combine both with icons and labels so your UI works for everyone.

💡 Best Practices

✅ Do

  • Provide monochrome fallbacks
  • Add icons alongside color cues
  • Use min-color for rich gradients
  • Distinguish media feature from property
  • Test contrast on all themes

❌ Don’t

  • Rely on color alone for meaning
  • Assume not (color) is common today
  • Confuse @media color with color:
  • Skip color-blind accessibility
  • Ignore print/grayscale output

Key Takeaways

Knowledge Unlocked

Five things to remember about color

Use these points when adapting styles to display capability.

5
Core concepts
02

(color)

Has color.

Match
03

not (color)

Monochrome.

Fallback
8 04

min-color

Bit depth.

Syntax
05

Icons + labels

Not color-only.

A11y

❓ Frequently Asked Questions

The color media feature detects whether the output device can display color. @media (color) matches color-capable screens; @media not (color) matches monochrome or grayscale devices such as some e-readers or specialized displays.
(color) applies styles when the device supports at least one bit of color per component — essentially all modern screens. not (color) applies when the device has zero color bits, meaning grayscale or monochrome output only.
The media feature is a device capability check inside @media rules. The color property sets the text or foreground color of an element. They share a name but solve completely different problems.
min-color matches when the device supports at least the specified number of bits per color component. For example, (min-color: 8) targets true-color displays with 8 or more bits, useful for enabling rich gradients on capable hardware.
Yes. (color), not (color), min-color, and max-color are supported in all modern browsers. Nearly all current devices match (color), but the feature remains useful for progressive enhancement and accessibility fallbacks.

Practice in the Live Editor

Open the HTML editor and experiment with @media (color) and accessible status badge patterns.

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