Dark Mode Accessibility: Contrast in Dark Themes
Also called: Dark theme, Night mode, prefers-color-scheme
Definition
Dark mode is a color scheme with light text on a dark background. When a website offers it, the text in that theme needs the same contrast as in the light theme: 4.5:1, or 3:1 for large text (WCAG 1.4.3).
Dark mode shows light text on a dark background instead of dark text on white. Many people turn it on to reduce glare or because bright screens hurt their eyes. But a dark theme is a second design – and the colors that work on white often fail on near-black, especially links and muted gray text. Good dark mode accessibility means checking that second design as carefully as the first.
What it means
WCAG has no separate rule for dark themes. The same color contrast thresholds apply to whatever text your page shows. WCAG 1.4.3 Contrast (Minimum) is a Level AA criterion of WCAG 2.2:
| Content | Minimum contrast ratio |
|---|---|
| Normal text | 4.5:1 |
| Large text (at least 18 pt, or 14 pt bold – about 24 px / 18.5 px) | 3:1 |
| Buttons, icons, input borders, focus indicators (1.4.11) | 3:1 |
| Logos, inactive controls, pure decoration | No requirement |
If your website ships a dark theme – through a toggle or the prefers-color-scheme media query – that theme is your code, so its text has to meet these values too. W3C notes that authors do not need to account for color changes made by the browser, except where caused by their own code. A dark version that the browser forces on its own is therefore not your responsibility; the night theme you designed is.
The rule for interface elements is non-text contrast (1.4.11): borders of input fields, icons and focus outlines need 3:1 against the dark background as well.
Who benefits: people with low vision who need strong contrast, people with light sensitivity or migraine who prefer dark backgrounds, and older users. Some people with astigmatism find light text on dark harder to read – which is why the choice should stay with the visitor rather than being forced.
Examples
A dark theme that follows the system setting and still keeps every color readable:
<style>
:root { --bg: #ffffff; --text: #374151; --link: #1D4ED8; }
@media (prefers-color-scheme: dark) {
:root { --bg: #121212; --text: #E4E4E7; --link: #93C5FD; }
}
body { background: var(--bg); color: var(--text); } /* 10.31:1 light, 14.76:1 dark */
a { color: var(--link); } /* 6.70:1 light, 10.39:1 dark */
</style>Define every color as a variable and give each one a dark value of its own. Check text, links, placeholders, borders and the focus outline in both themes. Let visitors choose and remember their choice. Keep information that is shown by color alone out of both themes – see use of color.
Invert colors with a filter and hope for the best – images and brand colors break. Use medium gray like #6B7280 for body text on #121212 (3.88:1, below 4.5:1). Forget the focus indicator – a dark outline disappears on a dark page.
How to check dark mode
Questions
Is dark mode required by WCAG?
No. WCAG does not require a dark theme. But if you offer one, its text and controls must meet the same contrast ratios as the default theme, because it is a presentation of your content created by your own code.
What contrast ratio does dark mode need?
The same as any theme: at least 4.5:1 for normal text and 3:1 for large text under WCAG 1.4.3, plus 3:1 for interface elements such as icons and field borders under 1.4.11.
Is pure white on black too much contrast?
WCAG sets only a minimum, not a maximum. Some readers find pure white on pure black tiring, so many designs use off-white on dark gray instead – for example #E4E4E7 on #121212 still reaches 14.76:1.
Does dark mode help people with visual impairments?
It helps many people with light sensitivity or certain eye conditions, while others read better on light backgrounds. That is why the visitor should be able to choose instead of the site forcing one theme.
How do I check the colors of my dark theme quickly?
Enter each text and background pair in the free contrast checker – it shows the ratio and whether it passes AA and AAA. Do this for both themes, not just the default.
Related terms
Color Contrast: WCAG Ratios and How to Check Them
Color contrast is the difference in brightness between text or interface elements and their background, measured as a ratio from 1:1 to 21:1. WCAG requires at least 4.5:1 for normal text and 3:1 for large text.
Read definition: Color Contrast: WCAG Ratios and How to Check ThemNon-text Contrast: 3:1 for Icons, Borders and Focus
Non-text Contrast is WCAG success criterion 1.4.11. The visual parts needed to identify user interface components and their states, and the parts of graphics needed to understand content, must have a contrast ratio of at least 3:1 against adjacent colors.
Read definition: Non-text Contrast: 3:1 for Icons, Borders and FocusFocus Visible: WCAG 2.4.7 and Visible Focus Styles
Focus visible means that a website shows a visible indicator – usually an outline – on the link, button or field that currently has keyboard focus. WCAG 2.4.7 requires it at Level AA.
Read definition: Focus Visible: WCAG 2.4.7 and Visible Focus StylesUse of Color: Never Rely on Color Alone
Use of Color is WCAG success criterion 1.4.1. Color must not be the only visual means of conveying information, indicating an action, prompting a response or distinguishing a visual element.
Read definition: Use of Color: Never Rely on Color Alone