# Dark Mode Accessibility: Contrast in Dark Themes

Source: https://allyway.ai/glossary/dark-mode-accessibility

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](https://allyway.ai/glossary/color-contrast) thresholds apply to whatever text your page shows. [WCAG 1.4.3 Contrast (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html) is a Level AA criterion of [WCAG 2.2](https://allyway.ai/regulations/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](https://allyway.ai/glossary/non-text-contrast) (1.4.11): borders of input fields, icons and focus outlines need 3:1 against the dark background as well.

> **Warning:** > **Your brand color may not survive the switch**
> A blue like `#1D4ED8` has a contrast ratio of 6.70:1 on white, but only about 2.80:1 on `#121212`. Links and buttons usually need a lighter shade in dark mode, such as `#93C5FD` (10.39:1).

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:

```html title="Example"
<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>
```

**Do:** Do

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](https://allyway.ai/glossary/use-of-color).

**Don't:** Don't

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](https://allyway.ai/glossary/focus-visible) – a dark outline disappears on a dark page.

## How to check dark mode



## Questions

Q: Is dark mode required by WCAG?
A: 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.

Q: What contrast ratio does dark mode need?
A: 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.

Q: Is pure white on black too much contrast?
A: 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.

Q: Does dark mode help people with visual impairments?
A: 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.

Q: How do I check the colors of my dark theme quickly?
A: Enter each text and background pair in the [free contrast checker](https://allyway.ai/free-wcag-contrast-checker) – it shows the ratio and whether it passes AA and AAA. Do this for both themes, not just the default.
