CSS color-index Media Feature

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

Definition and Usage

The color-index media feature tests how many entries are in the output device’s color lookup table (palette). If the device does not use a lookup table, the value is 0.

It is a range feature: use (color-index), (color-index: <integer>), (min-color-index: <integer>), and (max-color-index: <integer>). This is different from color (bits per component) and color-gamut (gamut width).

Limited availability.

Not Baseline — missing or incomplete in some widely used browsers. Most modern true-color screens report 0, so queries rarely match phones and desktops. Use it as progressive simplification for indexed-color hardware.

CSS Syntax

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

Example: @media (min-color-index: 256) { … }. The integer is palette entries.

Feature Values

QueryDescriptionTry it
(color-index)Matches indexed-color devices (palette size > 0)Try it
(min-color-index: 256)At least 256 palette entriesTry it
(max-color-index: 256)At most 256 palette entriesTry it
(color-index: 0)No lookup table (typical true-color displays)Try it
(color-index: 8)Exact palette size of 8 entriesTry it

How to Use color-index

Keep full-color styles as the default; simplify only when an indexed palette is detected.

  1. Design for normal true-color screens first.
  2. Add @media (color-index) or (max-color-index: …) to simplify colors on limited palettes.
  3. Prefer high-contrast, fewer hues — palette devices map colors poorly.
  4. Pair with color / monochrome when you also care about bit depth or grayscale.
PieceRequired?Role
Base true-color stylesYesWhat most visitors see
@media (color-index…)OptionalSimplifies for indexed palettes
Integer palette sizeFor min/max/exactNumber of lookup-table entries
Browser support checkRecommendedFeature has limited availability

Live Preview

This page checks your browser with matchMedia. On a typical phone or laptop you will often see no match for (color-index) and a match for (color-index: 0).

Device checks

Zero means “no color lookup table,” which is normal for true-color displays.

Results
  • (color-index): …
  • (min-color-index: 256): …
  • (color-index: 0): …

Sample note: styles inside indexed queries may not apply here.

Checking…

CSS Examples

Each snippet focuses on color-index. On most modern screens these indexed rules will not apply — that is expected. Use Try It Yourself for a live editor.

Example 1 — Any Indexed Device

Change text color when a color lookup table exists.

CSS
<style>
  p {
    color: black;
  }

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

<p>Crimson only on indexed-color devices.</p>
Try It Yourself

How It Works

  1. Set a base color. Black works on every device.
  2. Query (color-index). Matches when palette size > 0.
  3. Override inside the block. Indexed devices get crimson.
  4. Expect black on phones. True-color screens usually report 0.

Example 2 — min-color-index: 256

Require at least 256 palette entries before enabling a richer accent.

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

  @media (min-color-index: 256) {
    p {
      color: #1475ef;
    }
  }
</style>

<p>Blue when the palette has 256+ entries.</p>
Try It Yourself

How It Works

  1. Keep a safe base. Slate text is the default.
  2. Use min-color-index: 256. Classic “at least 8-bit palette” threshold.
  3. Enhance only then. Blue applies on larger indexed palettes.
  4. Still rare today. Most screens never enter this block.

Example 3 — color-index: 0

Style true-color devices that report no lookup table.

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

  @media (color-index: 0) {
    p {
      background: #dbeafe;
      border: 1px solid #2563eb;
    }
  }
</style>

<p>Blue panel on non-indexed (true-color) devices.</p>
Try It Yourself

How It Works

  1. Start with a neutral panel.
  2. Match exact zero. (color-index: 0) means no lookup table.
  3. Common on modern screens. You will often see the blue panel here.
  4. Use carefully. Prefer positive indexed queries when simplifying for limited palettes.

Edge Cases & Pitfalls

Most confusion comes from expecting phones to report a palette size.

limited

Not Baseline

Support is incomplete across major browsers. Never make critical layout depend only on color-index.

zero

Zero is normal today

True-color devices often report 0 (no lookup table). That does not mean “no color” — use color for that.

vs color

Different from bit depth

color = bits per RGB channel. color-index = palette entries. Do not mix the integers.

niche

Niche progressive enhancement

Useful for learning and specialized hardware. For everyday sites, prefer contrast, color-gamut, and solid defaults.

Browser Support

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

✓ Limited availability · Not Baseline

color-index

Implemented in some engines, missing or incomplete in others. Even where supported, modern true-color devices often report 0.

55% Limited
Google Chrome Partial / varies
Check current docs
Mozilla Firefox Supported
Full support
Apple Safari Limited
Check current docs
Microsoft Edge Partial / varies
Check current docs
Opera Partial / varies
Check current docs
Samsung Internet Partial / varies
Check current docs
Internet Explorer Legacy
Older support varies
@media (color-index) Limited · Not Baseline

Bottom line: Treat as progressive simplification only. Keep full-color defaults. This is not a JavaScript runtime API.

Key Takeaways

  • Role: count entries in a color lookup table (palette).
  • Zero means no indexed table — common on true-color screens.
  • Range forms: min- / max-color-index for thresholds like 256.
  • Limited availability — enhance, don’t depend on it.

One line: color-index asks “how big is the palette?” — usually zero on modern screens, handy for niche indexed displays.

Frequently Asked Questions

It reports how many entries are in the output device’s color lookup table (palette). The value is zero when the device does not use an indexed color table.
The boolean form matches when the palette size is greater than zero — an indexed-color device. Most modern true-color screens report zero and do not match.
color reports bits per RGB component. color-index reports palette entries in a lookup table. They measure different display models.
They are range forms. For example, (min-color-index: 256) matches devices with at least 256 palette entries.
Rarely. Phones and monitors usually use true color, so the feature is mainly for specialized or legacy indexed-color hardware — treat it as progressive simplification.
No. MDN lists Limited availability — it does not work in some widely used browsers. It is a browser CSS media feature, not a Node.js API.

Next: display-mode

Learn how to style for browser, standalone, and related display modes.

display-mode 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