The inverted-colors media feature detects when the OS inverts page colors for accessibility. Adapt styles for high-contrast inverted displays.
01
@media
Media query.
02
inverted
Colors flipped.
03
none
Normal display.
04
A11y
Accessibility.
05
vs dark
Not dark mode.
06
Images
Fix visuals.
Fundamentals
Introduction
Some users enable system color inversion for better readability — for example iOS Smart Invert or classic invert accessibility settings. When active, the browser or OS flips light and dark colors across the screen.
The @media (inverted-colors) feature lets you detect this setting and adjust your CSS so content remains clear, images don’t look broken, and contrast stays usable.
Definition and Usage
Write @media (inverted-colors: inverted) for inverted mode, or @media (inverted-colors: none) for normal colors. Use these queries to simplify gradients, strengthen borders, and fix media that inverts poorly.
💡
Beginner Tip
This is not the same as dark mode. Dark mode uses prefers-color-scheme: dark. Inverted-colors detects OS-level color flipping, which is a separate accessibility feature.
Foundation
📝 Syntax
Use inverted or none inside an @media rule:
syntax.css
/* System color inversion is active */@media(inverted-colors:inverted){/* Adapt for inverted display */}/* Normal color display */@media(inverted-colors:none){/* Standard styles */}
Accepted Values
inverted — The user agent or OS is inverting page colors (accessibility inversion active).
none — Colors display normally with no system inversion applied (default for most users).
inverted-colors vs prefers-color-scheme
(inverted-colors: inverted) OS flips all colors for high contrast. Found in Smart Invert and similar accessibility settings.
(prefers-color-scheme: dark) User prefers a dark theme. The site chooses dark palette colors — not a system-wide color flip.
Gradients and soft shadows can become muddy after inversion. Flat colors and borders stay readable.
Example 4 — inverted-colors vs prefers-color-scheme
Use both features for different user preferences:
inverted-colors-vs-dark.css
/* User prefers dark theme */@media(prefers-color-scheme:dark){body{background:#1e293b;color:#f1f5f9;}}/* System color inversion active */@media(inverted-colors:inverted){.decorative-bg{background-image:none;}a{text-decoration:underline;text-underline-offset:2px;}}
Dark mode handles theme preference; inverted-colors handles OS color flipping. Use both for inclusive design.
Tips
💬 Usage Tips
Progressive enhancement — Base design should work without inverted-colors rules.
Test on Safari iOS — Enable Smart Invert in Accessibility settings.
Simplify visuals — Flat colors beat complex gradients when inverted.
Keep link underlines — Strengthen link affordance in inverted mode.
Don’t rely on color alone — Use icons, labels, and borders too.
Watch Out
⚠️ Common Pitfalls
Confusing with dark mode — inverted-colors ≠ prefers-color-scheme: dark.
Assuming wide support — Limited browser support; always provide fallbacks.
Fighting the OS — Avoid colors that double-invert into unreadable results.
Hiding all images — Only replace images that truly break; keep meaningful ones.
Using filter: invert() — CSS filter inversion is different from this media feature.
A11y
♿ Accessibility
Respect user settings — Users enable inversion for vision needs; don’t override it.
WCAG contrast — Maintain 4.5:1 text contrast in both modes.
Focus indicators — Keep visible focus rings in inverted mode.
Semantic HTML — Headings, labels, and landmarks help all users.
Test with real settings — Enable system inversion on a phone or Mac to verify.
🧠 How inverted-colors Works
1
User enables inversion
They turn on Smart Invert or classic invert in system accessibility settings.
Setting
2
Browser reports state
The user agent sets inverted-colors: inverted or none.
Detect
3
@media rules apply
Your CSS adapts themes, images, and borders for inverted display.
Apply
=
♿
Inclusive visuals
Content stays readable for users who depend on color inversion.
Compatibility
🖥 Browser Compatibility
The inverted-colors media feature has limited support compared to other media queries. Safari on iOS and macOS is the primary supporter.
⚠ Limited · Progressive enhancement
System color inversion queries
Best supported in Safari. Use as an enhancement, not a requirement.
45%Global support
inverted-colors media feature~45% supported
Bottom line: Use inverted-colors as progressive enhancement alongside prefers-color-scheme and strong baseline contrast. Test on Safari with Smart Invert enabled.
Wrap Up
🎉 Conclusion
The inverted-colors media feature detects system color inversion, helping you build more inclusive interfaces for users who rely on high-contrast inverted displays.
Adapt themes, simplify cards, fix problematic images, and strengthen link affordance when inverted matches. Always provide a solid default design and use prefers-color-scheme for broader dark-mode support.
Use these points when building accessible color-aware layouts.
5
Core concepts
Inv01
inverted
OS flip on.
Value
N02
none
Normal.
Default
A11y03
Access
Vision aid.
Purpose
≠04
Not dark
Color-scheme.
Compare
Saf05
~45%
Safari main.
Compat
❓ Frequently Asked Questions
The inverted-colors media feature detects whether the user has enabled a system-level color inversion mode — often used for accessibility. Use @media (inverted-colors: inverted) to adapt styles when colors are inverted, and @media (inverted-colors: none) for normal display.
Two values: inverted (the OS or browser is inverting page colors) and none (colors display normally with no system inversion active).
No. Dark mode is typically detected with @media (prefers-color-scheme: dark). inverted-colors detects system color inversion, which flips colors for high contrast — a different accessibility feature found in iOS Smart Invert and similar settings.
Use it to simplify gradients and shadows, fix images that look wrong when inverted, strengthen borders for readability, and avoid double-inverting elements that already provide high contrast.
Support is more limited than prefers-color-scheme. Safari on iOS and macOS is the primary supporter. Treat it as progressive enhancement alongside semantic HTML, good contrast, and prefers-color-scheme.