CSS color Media Feature

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

Definition and Usage

The color media feature tests how many bits per color component (red, green, blue) the output device supports. Use it inside @media to enhance styles on color screens and keep simple fallbacks for monochrome output.

It is a range feature: you can use (color), (color: <integer>), (min-color: <integer>), and (max-color: <integer>). A value of 0 means the device is not a color device. This is not the same as the color property.

Baseline widely available.

Supported across modern browsers since mid‑2015. Almost every phone and monitor matches (color); use it for progressive enhancement, not as your only layout switch.

CSS Syntax

syntax.css
@media (color) | (color: <integer>) | (min-color: <integer>) | (max-color: <integer>) { … }

Example: @media (min-color: 8) { … }. The integer is bits per component.

Feature Values

QueryDescriptionTry it
(color)Matches any color device (bits > 0)Try it
(min-color: 8)At least 8 bits per component (typical true color)Try it
not (color)Non-color / monochrome output (bits = 0)Try it
(max-color: 8)At most 8 bits per componentTry it
(color: 0)Explicit zero — same idea as non-color devicesTry it

How to Use color

Write safe base styles first, then layer color enhancements with @media.

  1. Style for the simplest case (readable without relying on rich color).
  2. Add @media (color) for color-capable screens.
  3. Optionally raise the bar with (min-color: 8) for richer accents or gradients.
  4. For grayscale-focused fallbacks, also learn monochrome; for gamut width, use color-gamut.
PieceRequired?Role
@media ruleYesWhere the feature is tested
Integer bitsFor min/max/exactBits per RGB component
Base stylesRecommendedLook fine when queries do not match
Companion featuresOptionalmonochrome, color-gamut, color-index

Live Preview

This page reads your browser’s matchMedia results for common color queries. The sample box also uses real @media rules.

Device checks

Most modern screens match both (color) and (min-color: 8).

Results
  • (color): …
  • (min-color: 8): …
  • not (color): …

Sample text styled by @media (color) / (min-color: 8).

Checking…

CSS Examples

Each snippet focuses on the color media feature. On a typical color screen, the color rules will apply. Use Try It Yourself for a live editor.

Example 1 — Any Color Device

Apply a color style when the device supports any color bits.

CSS
<style>
  p {
    color: black;
  }

  @media (color) {
    p {
      color: crimson;
    }
  }
</style>

<p>This text turns crimson on color devices.</p>
Try It Yourself

How It Works

  1. Set a base color. color: black works on every device.
  2. Query (color). The boolean form matches when bits per component > 0.
  3. Override inside the media block. Color screens get crimson.
  4. Modern phones match. You will usually see the crimson text here.

Example 2 — min-color: 8

Require at least 8 bits per component before enabling a richer accent.

CSS
<style>
  p {
    color: #334155;
  }

  @media (min-color: 8) {
    p {
      color: #16a34a;
    }
  }
</style>

<p>Green on typical true-color displays.</p>
Try It Yourself

How It Works

  1. Keep a safe base. Slate text is readable without rich color.
  2. Use min-color: 8. Matches devices with at least 8 bits per channel.
  3. Enhance, don’t require. Gradients and accents belong in this block.
  4. Most screens qualify. True-color LCD/OLED panels commonly report 8+.

Example 3 — not (color)

Provide a monochrome-friendly style when the device has no color bits.

CSS
<style>
  p {
    color: #0f172a;
    background: #f8fafc;
    padding: 8px;
  }

  @media not (color) {
    p {
      color: #000;
      background: #fff;
      border: 2px solid #000;
    }
  }
</style>

<p>High-contrast fallback for non-color devices.</p>
Try It Yourself

How It Works

  1. Start with normal styles for color screens.
  2. Negate the feature. not (color) matches when bits = 0.
  3. Use contrast, not hue. Borders and black/white carry meaning without color.
  4. Rare on phones. You may not see the fallback here; it still matters for specialized displays.

Edge Cases & Pitfalls

Most mistakes come from confusing this feature with the color property or expecting rare monochrome matches.

vs property

Not the color property

This media feature does not set text color. Use the color property for that. The media feature only answers “how many bits per channel?”

bits

Smallest channel wins

If red/blue use 5 bits and green uses 6, the device counts as 5 bits per component. Indexed color uses the table’s minimum.

rare

not (color) rarely matches

Phones and monitors almost always match (color). Keep monochrome styles as progressive fallbacks, not your primary design path.

gamut

Bits ≠ wide gamut

color is bit depth. Wide color ranges use color-gamut (srgb, p3, rec2020).

Browser Support

The color media feature is a browser CSS capability query. Node.js, Deno, and Bun do not evaluate it.

✓ Baseline · Widely available

color

Supported in Chrome, Firefox, Safari, Edge, Opera, and older browsers that implement CSS media queries. Boolean, min-, and max- forms are safe for production.

99% Global support
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 9+
Full support
@media (color) Baseline · Widely available

Bottom line: Safe to use for progressive color enhancement. Almost all consumer devices match (color). This is not a JavaScript runtime API.

Key Takeaways

  • Role: report bits per RGB component of the output device.
  • Boolean (color) means “any color device.” 0 means none.
  • Use min-color to gate richer styles; keep solid base styles outside the query.
  • Different from the color property and from color-gamut.

One line: @media (color) asks “can this screen show color?” — enhance when yes, stay readable when no.

Frequently Asked Questions

It reports how many bits per color component (red, green, blue) the output device supports. Use it inside @media to style color-capable screens differently from monochrome ones.
The boolean form matches when the device has more than zero bits per color component — essentially any color display. Zero means a non-color (monochrome) device.
The media feature checks device capability inside @media. The color property sets an element’s foreground text color. Same word, different jobs.
min-color matches when the device supports at least that many bits per component. For example, (min-color: 8) targets typical true-color displays.
If channels use different bit counts, the smallest number is used. Indexed-color devices use the minimum bits per component in the color table.
Yes. It is Baseline Widely available. It is a browser CSS media feature, not a Node.js API.

Next: color-gamut

Learn how to detect wide-gamut displays with srgb, p3, and rec2020.

color-gamut 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