CSS color-index Media Feature

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

What You’ll Learn

The color-index media feature detects how many colors exist in a device’s palette lookup table. Use it to simplify designs on indexed-color or limited-palette displays.

01

@media

Media query.

02

Palette

Lookup table.

03

min-

At least N.

04

max-

At most N.

05

vs color

Bits vs index.

06

Legacy

Niche use.

Introduction

The @media color-index feature targets devices based on the number of entries in their color lookup table — the palette used by indexed-color displays. Instead of mixing millions of RGB values directly, some hardware picks colors from a fixed table of 256 (or fewer) swatches.

Most modern phones, laptops, and monitors report a very high color-index value. This feature is mainly useful for progressive simplification on legacy or specialized hardware, or when you want to understand how CSS models display capabilities.

Definition and Usage

Write integer values inside media queries: @media (min-color-index: 256), @media (max-color-index: 256), or an exact @media (color-index: 256). The boolean form (color-index) matches any indexed-color device.

💡
Beginner Tip

256 palette entries often corresponds to classic 8-bit indexed color. Prefer min-color-index and max-color-index over exact matches for more reliable responsive rules.

📝 Syntax

Use positive integers with the color-index media feature:

syntax.css
@media (color-index: 256) {
  /* Exact 256-entry palette */
}

@media (min-color-index: 256) {
  /* At least 256 palette colors */
}

@media (max-color-index: 256) {
  /* At most 256 palette colors */
}

@media (color-index) {
  /* Any indexed-color device */
}

Feature Variants

  • color-index — Boolean or exact integer for palette table size.
  • min-color-index — Matches when the palette has at least N entries.
  • max-color-index — Matches when the palette has at most N entries (limited-color devices).

color-index vs color Media Feature

(color: 8) / min-color: 8 Measures bits per color component in true-color displays (e.g. 8-bit red, green, blue channels).
(color-index: 256) Measures palette table size for indexed-color displays that pick from a fixed swatch list.

Basic Example

color-index-basic.css
@media (min-color-index: 256) {
  body {
    background-color: #dbeafe;
  }
  p {
    color: #1e3a8a;
  }
}

@media (max-color-index: 256) {
  body {
    background-color: #e2e8f0;
  }
  p {
    color: #1e293b;
  }
}

Default Value

There is no CSS default. The browser reports the device’s palette capability at runtime.

Syntax Rules

  • Values must be non-negative integers (typically 2, 16, 256, etc.).
  • Prefer min- and max- ranges over exact palette matches.
  • Use max-color-index to simplify UI on limited palettes.
  • Distinct from color (bit depth) and color-gamut (gamut width).
  • On modern hardware, low palette queries rarely match — treat as progressive enhancement.

Related Topics

@media (min-color-index: 256) @media (max-color-index: 256) @media (color-index)

⚡ Quick Reference

QuestionAnswer
Feature namecolor-index, min-color-index, max-color-index
What it detectsNumber of colors in the device palette lookup table
Common legacy value256 (8-bit indexed palette)
Simplify limited palettes@media (max-color-index: 256)
Modern devicesVery high color-index; low-palette queries rarely match
Browser supportAll modern browsers

When to Use color-index

Reach for color-index in specialized scenarios:

  • Legacy hardware — Simplify colors on old indexed-color screens.
  • Embedded displays — Adapt UI for industrial panels with small palettes.
  • Progressive simplification — Reduce gradient complexity on limited palettes.
  • Educational demos — Teach how CSS models display color capabilities.
  • Pair with color feature — Combine bit-depth and palette queries for fine-grained control.

👀 Live Preview

This demo shows a full palette on modern displays. On devices with max-color-index: 256, extra swatches would be hidden:

Palette Size Demo Full palette on high color-index displays

Examples Gallery

Practice color-index with palette thresholds, simplified UI, and comparisons to the color feature.

📜 Core Patterns

Adapt styles based on palette lookup table size.

Example 1 — Styles when palette has 256+ colors

Apply richer colors when the device supports at least a 256-entry palette:

color-index-256.css
@media (min-color-index: 256) {
  body {
    background-color: #dbeafe;
  }
  p {
    color: #1e3a8a;
  }
}
Try It Yourself

How It Works

Devices with at least 256 palette entries get the richer blue theme from the reference pattern.

Example 2 — Simplified UI on small palettes

Strip gradients and use flat colors when the palette has at most 256 entries:

color-index-simple.css
.card {
  padding: 1rem;
  background: linear-gradient(135deg, #dbeafe, #fce7f3);
  border: 1px solid #93c5fd;
  border-radius: 0.5rem;
}

@media (max-color-index: 256) {
  .card {
    background: #e2e8f0;
    border-color: #64748b;
    box-shadow: none;
  }
}
Try It Yourself

How It Works

Gradients may band or dither on tiny palettes; flat colors stay predictable.

Example 3 — Disable complex backgrounds on indexed color

Use the boolean (color-index) form to detect indexed-color output:

color-index-boolean.css
.hero {
  padding: 2rem;
  background: #2563eb;
  color: #fff;
}

@media (color-index) and (max-color-index: 256) {
  .hero {
    background: #334155;
    background-image: none;
  }
}

@media (min-color-index: 4096) {
  .hero {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
  }
}
Try It Yourself

How It Works

Small indexed palettes get a solid hero; large palettes unlock the gradient enhancement.

Example 4 — color-index vs color bit depth

Combine palette size and bit-depth queries for layered display adaptation:

color-index-vs-color.css
/* True-color bit depth */
@media (min-color: 8) {
  .panel {
    background: #eff6ff;
  }
}

/* Indexed palette size */
@media (max-color-index: 256) {
  .panel {
    background: #f1f5f9;
    border: 2px solid #334155;
  }
}

.panel {
  padding: 1rem;
  border-radius: 0.5rem;
}
Try It Yourself

How It Works

color and color-index measure different hardware traits and can be combined in one design system.

💬 Usage Tips

  • Use max-color-index — Simplify UI when palette size is small; more practical than exact matches.
  • Flat over gradients — Limited palettes render flat colors more faithfully than smooth gradients.
  • High contrast borders — Add strong borders on low palette devices when subtle shades collapse.
  • Modern reality — Most users won’t trigger low palette queries; keep defaults polished.
  • Learn the triocolor, color-index, and color-gamut cover different display traits.

⚠️ Common Pitfalls

  • Expecting matches on modern phones — Typical devices report huge palette sizes; low-index queries won’t fire.
  • Confusing with color — Bit depth ≠ palette table size; read the feature names carefully.
  • Exact integer matches(color-index: 256) is fragile; prefer min/max ranges.
  • Over-engineering — Don’t build entire layouts around color-index unless you target legacy hardware.
  • Color-only cues — Limited palettes make subtle shade differences harder; use icons and labels.

♿ Accessibility

  • Strong contrast — On limited palettes, subtle grays may collapse; use high-contrast pairs.
  • Do not rely on fine shades — Status colors may dither; pair with text and icons.
  • Readable defaults — Base styles must work even when enhancement queries never match.
  • Test simplification — Verify that max-color-index fallbacks remain fully usable.
  • Color blindness — Palette limits compound confusion between similar hues.

🧠 How color-index Works

1

Browser queries palette

The user agent reads how many entries exist in the device color lookup table.

Query
2

Integer compared

color-index, min-, or max- values are matched against the reported size.

Match
3

Styles adapt

Matching rules simplify or enrich colors based on palette capacity.

Apply
=

Palette-aware design

UI stays readable on indexed-color and limited-palette hardware.

🖥 Browser Compatibility

The color-index media feature is supported in modern browsers, though practical use is niche today.

Baseline · Modern browsers

Palette queries supported

Works in Chrome, Firefox, Safari, and Edge.

96% Global support
color-index media feature 96% supported

Bottom line: Supported everywhere, but low-palette matches are rare on current consumer hardware. Use for progressive simplification, not core layout logic.

🎉 Conclusion

The color-index media feature targets devices by palette lookup table size. While uncommon in everyday responsive design, it teaches an important distinction: indexed-color hardware picks from a fixed swatch list rather than mixing millions of RGB values directly.

Use max-color-index to simplify on limited palettes, pair with the color and color-gamut features for a complete picture of display capability, and always ship polished defaults for modern screens.

💡 Best Practices

✅ Do

  • Use min- and max-color-index ranges
  • Simplify on small palettes
  • Prefer flat colors over gradients
  • Combine with color feature when needed
  • Keep modern defaults polished

❌ Don’t

  • Confuse color-index with color
  • Depend on low palette matches today
  • Use exact palette integers only
  • Rely on subtle shade differences
  • Skip accessible icons and labels

Key Takeaways

Knowledge Unlocked

Five things to remember about color-index

Use these points when adapting to palette-limited displays.

5
Core concepts
256 02

Classic

8-bit index.

Value
max 03

max-

Simplify UI.

Pattern
8b 04

vs color

Bits vs index.

Compare
🌐 05

Niche today

Legacy use.

Context

❓ Frequently Asked Questions

The color-index media feature detects how many entries are in a device color lookup table — the palette size for indexed-color displays. Use @media (min-color-index: 256) or (max-color-index: 256) to adapt styles for limited-palette hardware.
The color media feature reports bits per color component (true-color depth). color-index reports the number of colors in an indexed palette lookup table. They measure different display characteristics.
color-index accepts positive integers. Use (color-index: 256) for an exact palette size, (min-color-index: 256) for at least 256 colors, or (max-color-index: 256) for at most 256 colors. The boolean (color-index) matches indexed-color devices with any palette.
Rarely for mainstream sites — most current displays support millions of colors. It remains useful for progressive simplification on very limited displays, embedded screens, or niche legacy hardware where a smaller palette improves consistency.
Yes. color-index, min-color-index, and max-color-index are supported in modern browsers. On typical phones and desktops the value is very high, so matching queries for low palette sizes is uncommon in everyday browsing.

Practice in the Live Editor

Open the HTML editor and experiment with @media (min-color-index: 256) and simplified palette fallbacks.

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