CSS inverted-colors Media Feature

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

What You’ll Learn

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.

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.

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

Basic Example

inverted-colors-basic.css
@media (inverted-colors: inverted) {
  body {
    background-color: #0f172a;
    color: #f8fafc;
  }
}

@media (inverted-colors: none) {
  body {
    background-color: #fff;
    color: #1e293b;
  }
}

Default Value

The default is effectively none — colors display normally unless the user enables system inversion.

Syntax Rules

  • Use explicit values: inverted or none (no boolean shorthand).
  • Treat as progressive enhancement — most users will match none.
  • Avoid fighting the OS inversion with conflicting background overrides.
  • Simplify gradients and shadows when inverted matches.
  • Pair with semantic HTML and WCAG contrast for baseline accessibility.

Related Topics

@media (inverted-colors: inverted) @media (inverted-colors: none) prefers-color-scheme: dark

⚡ Quick Reference

QuestionAnswer
Feature nameinverted-colors
Valuesinverted, none
What it detectsSystem-level color inversion (accessibility)
Default for most usersnone
Not the same asprefers-color-scheme: dark
Primary use caseAccessibility & high-contrast adaptation
Browser supportLimited — Safari primary; progressive enhancement

When to Use inverted-colors

Reach for inverted-colors when system inversion affects readability:

  • Accessibility support — Help users who rely on inverted color modes.
  • Fix broken images — Swap or hide photos that invert poorly.
  • Simplify gradients — Replace complex gradients with flat colors when inverted.
  • Strengthen borders — Add visible outlines so UI boundaries stay clear.
  • Remove decorative shadows — Shadows may look odd after color inversion.

👀 Live Preview

With normal colors this block is white. If your device has system color inversion enabled, it switches to a dark high-contrast style:

Inverted Colors Demo @media (inverted-colors)

Examples Gallery

Practice inverted-colors with page themes, image handling, card simplification, and comparisons to dark mode.

📜 Core Patterns

Adapt page colors when system inversion is active.

Example 1 — Page theme for inverted colors

Apply dark high-contrast styles when inversion is active; light theme otherwise:

inverted-colors-theme.css
@media (inverted-colors: inverted) {
  body {
    background-color: #0f172a;
    color: #f8fafc;
  }
}

@media (inverted-colors: none) {
  body {
    background-color: #fff;
    color: #1e293b;
  }
}
Try It Yourself

How It Works

Work with the OS inversion rather than against it by providing intentional high-contrast colors.

Example 2 — Fix images that invert poorly

Hide decorative photos or show a simplified version when colors are inverted:

inverted-colors-images.css
.hero-photo {
  max-width: 100%;
  border-radius: 0.5rem;
}

.hero-placeholder {
  display: none;
  padding: 2rem;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 0.5rem;
  text-align: center;
}

@media (inverted-colors: inverted) {
  .hero-photo {
    display: none;
  }
  .hero-placeholder {
    display: block;
  }
}
Try It Yourself

How It Works

Photos often look wrong when inverted. A text placeholder keeps content meaningful without visual artifacts.

Example 3 — Simplify cards when inverted

Remove gradients and shadows; use flat colors and strong borders:

inverted-colors-cards.css
.card {
  padding: 1rem;
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

@media (inverted-colors: inverted) {
  .card {
    background: #1e293b;
    border: 2px solid #f8fafc;
    box-shadow: none;
    color: #f8fafc;
  }
}
Try It Yourself

How It Works

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;
  }
}
Try It Yourself

How It Works

Dark mode handles theme preference; inverted-colors handles OS color flipping. Use both for inclusive design.

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

⚠️ Common Pitfalls

  • Confusing with dark modeinverted-colorsprefers-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.

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

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

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

💡 Best Practices

✅ Do

  • Test with Smart Invert
  • Simplify when inverted
  • Strengthen borders/links
  • Use progressive enhancement
  • Pair with color-scheme

❌ Don’t

  • Confuse with dark mode
  • Require it for core UX
  • Fight OS inversion
  • Use filter: invert() instead
  • Hide all images blindly

Key Takeaways

Knowledge Unlocked

Five things to remember about inverted-colors

Use these points when building accessible color-aware layouts.

5
Core concepts
N 02

none

Normal.

Default
A11y 03

Access

Vision aid.

Purpose
04

Not dark

Color-scheme.

Compare
Saf 05

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

Practice in the Live Editor

Open the HTML editor and experiment with @media (inverted-colors: inverted) accessibility patterns.

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