Skip to main content
WCAGrules
Quick navigation

Glossary · Accessibility term

Dark mode

Also called: prefers-color-scheme

Dark mode is a second colour scheme with a dark background. You offer it by honouring what the visitor has set in their operating system or browser, or by a toggle on the page, or by both. It is a separate palette rather than an inversion of the first one. Whichever scheme somebody lands in is the presentation they get, so the pairs in it have to clear the same thresholds the light ones do. WCAG scopes contrast to the colour pairs an author would expect to appear together, and a palette you wrote is a presentation you caused. There is a route for a scheme that deliberately falls short, and it is the alternate-version one, which means a conforming scheme has to stay reachable and the switch between them has to work for everybody. Nothing in WCAG requires a dark mode at all. What WCAG does require is that the one you ship works, which is a bigger job than it looks, because a second palette doubles the surface every contrast rule applies to.

In practice

It arrives two ways, and the media query is only half the machinery. The query reports the preference, which the visitor can set in the browser as well as in the operating system. A separate CSS property tells the browser which schemes your page supports, and that is what makes native form controls, scrollbars and the page canvas follow the theme instead of staying stubbornly white. The query now has two values rather than three, and light also means the person never expressed a preference, so write light as the default and treat dark as the override.

Building it as an inversion is the common mistake, and there is a formula behind why it fails. Relative luminance weights the channels unequally, and blue contributes only 7.22% of it, so a saturated brand blue is a very dark colour by the numbers. On a light background it has contrast to spare. On a dark one it has almost none. Brand blues and purples are usually the first casualties of a dark palette, and inverting the greys produces a set of values nobody chose. Measure the pairs rather than trusting the pattern, because the numbers are what the rule reads.

Focus indicators are the next thing to go, and they answer to three rules rather than one. They have to be visible, and they have to clear 3:1 against what sits next to them. At Level AAA the measurement changes again, to the contrast between the same pixels in the focused and unfocused states, which is the one most likely to break when a palette flips. The preference reaches inside cross-origin embeds too, so the video player, the map and the logo stranded white in the middle of a dark page can follow it. Can, not will. The embedded document has to have been built to respond, and where it was not, nothing you write on the outside restyles it for you.

Why it matters

A palette that passes in light mode is not a palette that passes. It is one of two, and the second one is usually the one nobody measured, because a scan reports whichever scheme it happened to load in and most runs never say which that was. Automation can emulate the preference and test both, so ask what the run actually covered rather than assuming either answer. There is one argument here that runs the other way and is worth knowing. WCAG encourages authors to offer colour adjustment mechanisms even where the combinations somebody picks fall below the thresholds, as long as a mechanism brings them back. So a theme toggle is something the standard wants rather than a risk to conformance, and a toggle producing a conforming version can even be the mechanism that reaches a conforming alternate version. That only holds if the toggle itself is operable by keyboard and named for a screen reader.

Dark mode is not forced colours

A dark theme is a second palette you wrote, which the visitor's system asks you for. Forced colours is the operating system replacing your palette outright, because the visitor told it to. One asks you to supply the colours. The other takes the choice away from you, and a team that has only ever tested a dark theme has not tested that.

Where this shows up on the site

Related terms

Knowing the word is the easy part.

Find out where your own site stands. The free scan checks 10 pages in a real browser against all 90 supported automated rules, separates 27 best-practice checks from its WCAG findings, and names the rule behind every result.

Run the free scan

Go somewhere useful

Find tools, resources and your workspace.

29 destinations