This feature is not Baseline because it does not work in some of the most widely-used browsers.
The inverted-colors CSS media feature is used to test if the user agent or the underlying operating system has inverted all colors.
Inversion of colors can have unpleasant side effects, such as shadows turning into highlights, which can reduce the readability of the content. Using this media feature, you can detect if inversion is happening and style the content accordingly while respecting user preference.
/* Keyword value */
@media (inverted-colors: inverted) {
/* styles to apply if inversion of colors is detected */
}
The inverted-colors feature is specified as one of the following keyword values:
This example demonstrates the effects of both inverted-colors media feature keyword values and when the inverted-colors media feature is not supported.
<p> If color inversion is detected, this text will appear blue on white (the inverse of yellow on black) along with a line over the text. If no color inversion is happening, the text will appear red on light gray without the line over the text. </p> <p> If the text is gray and no overline is present, it means your browser doesn't support the <code>inverted-colors</code> media feature. </p>
p {
color: gray;
}
@media (inverted-colors: inverted) {
p {
background: black;
color: yellow;
text-decoration: overline;
}
}
@media (inverted-colors: none) {
p {
background: #eeeeee;
color: red;
}
}
| Specification |
|---|
| Media Queries Level 5> # inverted> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
inverted-colors |
No | No | 114 | No | 9.1 | No | No | No | 10 | No | No | 10 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/inverted-colors