CSS monochrome Media Feature

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

Definition and Usage

The monochrome media feature reports the number of bits per pixel in the output device’s monochrome frame buffer.

If the device is not monochrome, the value is 0 (typical color screens). A positive integer means a grayscale display. It is a range feature, so you can also use min-monochrome and max-monochrome. Pair it with color when you need to distinguish color vs grayscale capability.

Baseline · Widely available.

Not deprecated. Standard-track Media Queries Level 4 feature. Real monochrome hardware is rare — treat positive matches as progressive enhancement.

CSS Syntax

syntax.css
@media (monochrome: <integer>) { … }

Also: @media (monochrome) { … } · @media (min-monochrome: 2) { … } · @media (max-monochrome: 8) { … }

Feature Values

FormDescriptionTry it
(monochrome)Boolean: matches when bits > 0 (any monochrome device)Try it
(monochrome: 0)Not monochrome — typical color screensTry it
(monochrome: N)Exact bits per pixel (e.g. 1, 2, 8)Try it
min- / max-Range queries for minimum or maximum bit depthTry it

How to Use monochrome

Style for color by default, then simplify when a monochrome buffer is reported.

  1. Ship readable color defaults that work everywhere.
  2. Add @media (monochrome) for grayscale-friendly contrast.
  3. Use (monochrome: 0) when you need an explicit color-device branch.
  4. Optionally refine with min-monochrome / max-monochrome for bit depth.
PieceRequired?Role
@mediaYesWraps the media feature
Integer / booleanYesBits per pixel, or truthy when > 0
Default stylesYesMost devices are color (0)
min- / max-OptionalRange checks on bit depth

Live Preview

What matchMedia reports on this device. Color screens usually match (monochrome: 0) only.

Detected monochrome queries

Green chips are active matches. Sample text follows real @media (monochrome…) rules when they apply.

Monochrome detection

Monochrome sample

(monochrome) (monochrome: 0) (min-monochrome: 2)

Checking…

CSS Examples

Each snippet focuses on monochrome. On most color devices only the : 0 branch matches. Use Try It Yourself for a live editor.

Example 1 — Any Monochrome Device

Boolean form: match when bits per pixel > 0.

CSS
p {
  display: none;
}

@media (monochrome) {
  p {
    display: block;
    color: #333;
  }
}
Try It Yourself

How It Works

  1. Hide by default. Color devices skip this message.
  2. Boolean query. @media (monochrome) means value > 0.
  3. Show grayscale copy. Dark gray text suits e-ink style displays.
  4. Rare match. Phones/monitors usually stay on display: none.

Example 2 — Non-Monochrome (Color) Devices

Target typical color screens with monochrome: 0.

CSS
p {
  color: #64748b;
}

@media (monochrome: 0) {
  p {
    color: #dc2626;
  }
}
Try It Yourself

How It Works

  1. Default slate text. Works even if the query fails.
  2. Match zero. Color devices report 0 bits in the mono buffer.
  3. Apply color styling. Red text is fine when color is available.
  4. Opposite of boolean. This branch is the common desktop/phone path.

Example 3 — Minimum Bit Depth

Require at least 2 bits per pixel with min-monochrome.

CSS
p {
  border: 1px solid #94a3b8;
}

@media (min-monochrome: 2) {
  p {
    border-width: 3px;
    border-color: #000;
  }
}
Try It Yourself

How It Works

  1. Thin default border. Fine for color screens.
  2. Range feature. min-monochrome: 2 needs at least 2 bits/pixel.
  3. Thicken details. Stronger edges help on limited grayscale depths.
  4. Pair with max-. Use max-monochrome when you need an upper bound.

Edge Cases & Pitfalls

If nothing looks “grayscale,” you are probably on a color screen.

zero

Color devices report 0

Phones, laptops, and most monitors match (monochrome: 0), not the boolean (monochrome).

vs color

Different from the color feature

color measures color channel depth. monochrome measures grayscale buffer depth. Check both when classifying a device.

boolean

(monochrome) means > 0

Like other media features, the bare keyword is true when the value is non-zero.

range

Use min- / max- for thresholds

Exact (monochrome: 8) is brittle. Prefer min-monochrome / max-monochrome for ranges.

defaults

Do not rely on a positive match

True mono hardware is uncommon. Keep contrast and hierarchy clear without the query.

Browser Support

monochrome is a browser media feature. Node.js, Deno, and Bun do not evaluate it.

✓ Baseline · Widely available

monochrome

Widely supported in modern browsers (Chrome, Firefox, Safari, Edge 79+). Matching a positive bit depth still depends on real monochrome hardware.

97% Query support
Google Chrome 4+
Full support
Mozilla Firefox 2+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 79+
Full support
Opera 10+
Full support
Samsung Internet 4+
Full support
Internet Explorer —
No support
@media (monochrome) Widely supported

Bottom line: Safe to teach and use as progressive enhancement. Expect (monochrome: 0) on ordinary color devices. It is not a runtime API.

Key Takeaways

  • Role: report grayscale bits per pixel (0 = color device).
  • Boolean: (monochrome) matches when the value is > 0.
  • Range: use min-monochrome / max-monochrome for thresholds.
  • Practice: enhance for mono; never depend on it for everyday color UIs.

One line: 0 means color; any positive value means grayscale bits — style accordingly, defaults first.

Frequently Asked Questions

It reports how many bits per pixel are in the device’s monochrome frame buffer. Color devices report 0. Positive integers mean a grayscale display.
The boolean form matches when the monochrome value is greater than 0 — any true monochrome device.
The output device is not monochrome (typical color screens). Most phones and monitors match (monochrome: 0).
color reports bits per color component on color devices. monochrome reports grayscale bit depth. A color phone usually matches color > 0 and monochrome: 0.
For e-readers, specialty grayscale hardware, or high-contrast fallbacks. On ordinary color screens the query rarely matches a positive value — keep solid defaults.
No. It is a CSS media feature evaluated by the browser layout engine, not a Node.js or server runtime feature.

Next: orientation

Learn the orientation media feature for portrait and landscape layouts.

orientation 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.

8 people found this page helpful