The inverted-colors media feature tests whether the user agent or OS has inverted all colors in the displayed area.
Use @media (inverted-colors: inverted) to adapt when inversion is on (for example iOS Smart Invert), and @media (inverted-colors: none) when colors are normal. Inversion can turn shadows into highlights and hurt readability — this query lets you soften those side effects while respecting the user’s setting.
Limited availability Not Baseline
Mainly supported in Safari. Chrome, Edge, and Firefox do not ship it yet. Use as progressive enhancement only — never require it for readable defaults.
Not dark mode.
Dark theme preference is prefers-color-scheme. inverted-colors is a separate accessibility inversion signal.
Syntax
CSS Syntax
syntax.css
@media (inverted-colors:none | inverted) { … }
Always wrap the feature in parentheses. Invalid forms like @media inverted-colors(inverted) do not work.
Each snippet focuses on inverted-colors. View Output shows the intended look; many desktop browsers will not match — use Try It Yourself and Safari when possible.
Example 1 — Styles When Inverted
Adapt text and background when the OS inverts colors.
CSS
p {
color: #64748b;
}
@media (inverted-colors: inverted) {
p {
background: #000;
color: #ff0;
text-decoration: overline;
}
}
Under OS invert, filter: invert(1) cancels the flip for the photo.
How It Works
Leave images alone by default. No filter when colors are normal.
Detect inverted. The media query fires when the OS flips every pixel.
Invert again.filter: invert(1) cancels the system invert for that image.
Use sparingly. Icons and UI chrome may need different treatment than photos.
Edge Cases & Pitfalls
If nothing changes on desktop Chrome, that is expected — check these next.
support
Safari-first today
Most Chromium and Firefox builds do not match. Defaults must already be readable without the query.
vs dark
Not prefers-color-scheme
Dark mode and color inversion are different OS settings. Style them separately.
plan
Colors flip again
Styles you set under inverted are themselves inverted by the OS. Design for the final on-screen result.
shadows
Shadows become highlights
Soft shadows and translucent overlays can look harsh after invert. Simplify them under inverted.
syntax
Parentheses required
Use @media (inverted-colors: inverted). Forms without parentheses are invalid.
Compatibility
Browser Support
inverted-colors is a browser media feature. Node.js, Deno, and Bun do not evaluate it.
✓ Limited availability
inverted-colors
Supported in Safari 9.1+ and Safari on iOS 10+. Chrome, Edge, Opera, and Firefox do not support it in production (Firefox may have a disabled flag). Use as progressive enhancement.
18%Global reach
Google Chrome—
No support
Mozilla Firefox—
No / flag
Apple Safari9.1+
Full support
Microsoft Edge—
No support
Opera—
No support
Samsung Internet—
No support
Internet Explorer—
No support
@media (inverted-colors)Safari primarily
Bottom line: Teach the syntax and ship safe defaults. Rely on Safari for real matching. It is not a runtime API.
Remember
Key Takeaways
Role: detect OS/user-agent color inversion.
Values:none and inverted inside @media (…).
Not dark mode: separate from prefers-color-scheme.
Practice: progressive enhancement; Safari is the main test target.
One line: detect system color inversion, fix harsh side effects, and never depend on the query for basic readability.
Frequently Asked Questions
It detects whether the user agent or OS has inverted all displayed colors (for example iOS Smart Invert). Use @media (inverted-colors: inverted) to adapt styles when inversion is active.
Two keywords: none (colors display normally) and inverted (all pixels in the displayed area are inverted).
No. Dark mode uses prefers-color-scheme. inverted-colors detects system-level color inversion, which flips colors for accessibility — a different preference.
Use it as progressive enhancement: soften shadows that become highlights, protect images that look wrong when inverted, and keep text readable after the OS flips colors.
Primarily Safari (macOS 9.1+, iOS 10+). Chrome, Edge, and Firefox do not support it in production yet. Treat it as Limited availability enhancement.
No. It is a CSS media feature evaluated by the browser layout engine, not a Node.js or server runtime feature.