prefers-color-scheme media queryBaseline · Widely available
The prefers-color-scheme CSS media query sets styles based on the requested color scheme, light or dark.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.
Browser support
DesktopChrome
1–75Not supported
76+Supportedsince Jul 30, 2019
Current: 155Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154Firefox
1–66Not supported
67+Supportedsince May 21, 2019
Current: 157Safari
1–12Not supported
12.1+Supportedsince Mar 25, 2019
Current: 27MobileChrome Android
18–75Not supported
76+Supportedsince Jul 30, 2019
Current: 155Firefox Android
4–66Not supported
67+Supportedsince May 21, 2019
Current: 157Safari iOS
1–12.2Not supported
13+Supportedsince Sep 19, 2019
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: prefers-color-scheme.
Feature detection
There’s no simple runtime check for this feature; rely on the support table and test in your target browsers.
Documentation (MDN)
Specification
Sub-features
Support for each part of the feature (3). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| @media.prefers-color-scheme | 76 | 79 | 67 | 12.1 | 76 | 67 | 13 |
| @media.prefers-color-scheme.respects-inherited-scheme | 129 | 129 | 105 | ✕ | 129 | 105 | ✕ |
| http.headers.Sec-CH-Prefers-Color-Scheme | 93 | 93 | ✕ | ✕ | 93 | ✕ | ✕ |