MobileCheck

How to test your website in dark mode on mobile

Updated October 20, 2026

Short answer: To support dark mode, add a prefers-color-scheme: dark block that switches text and background colors together, and declare <meta name="color-scheme" content="light dark"> (or "light" for a light-only site) so form controls and scrollbars match. Dark mode is optional, but whatever visitors see must still meet WCAG AA contrast: 4.5:1 for normal text, 3:1 for large text.

On this page
  1. How do phones switch websites to dark mode?
  2. What breaks in dark mode?
  3. See how your site reads on phones
  4. How MobileCheck checks dark mode
  5. How do I support dark mode properly?
  6. On iPhone vs Android
  7. How do I check the fix?
  8. Frequently asked questions
  9. Sources

Your site doesn't have to turn dark when a phone is in dark mode, but it must never end up half-dark: dark text on a dark background, a black logo vanishing into a black header, or white form fields glowing in a dark design. Declare which color schemes you support with color-scheme, switch text and background colors together in a prefers-color-scheme block, and check the result in both modes. This guide explains how phones handle dark mode on the web and how to test your site in it.

How do phones switch websites to dark mode?

On both iOS and Android, dark mode is a system setting (Appearance on iPhone, Dark theme on Android). Browsers pass it to websites through the prefers-color-scheme media query. If your CSS has a prefers-color-scheme: dark block, it applies; if not, the site normally stays exactly as it is in light mode.

There's one important exception: some browsers can darken sites that don't support dark mode themselves. Samsung Internet has a dark mode option that can apply to web pages, and Chromium-based browsers on Android have had automatic darkening options for web content, depending on version and settings. These algorithms invert or adjust colors on their own, and the results vary: photos may be left alone while backgrounds flip, or brand colors may shift. Safari on iPhone doesn't force dark styling onto pages by default.

What breaks in dark mode?

Dark mode problems are mostly contrast problems. A design that relies on default colors in some places and hard-coded colors in others can end up with dark text on a dark background once the defaults change. Typical trouble spots:

  • Text with no explicit color sitting on a container with a hard-coded light or dark background.
  • Form fields, buttons and scrollbars that follow the system theme while the page around them doesn't.
  • Logos and icons saved as transparent PNG or SVG in black, which disappear on dark backgrounds.
  • Embedded widgets (chat, maps, payment forms) styled for light mode only.

If contrast drops below WCAG AA (4.5:1 for normal text, 3:1 for large text) the text is hard to read, which is exactly what our low contrast guide covers in detail.

How MobileCheck checks dark mode

Dark mode is one of the four scenarios MobileCheck runs for every device, next to the normal view, large text and the opened mobile menu. On the same page load, we switch the browser to prefers-color-scheme: dark, take a full-page screenshot, and check:

  • Contrast: text below WCAG AA against its actual background is flagged and highlighted.
  • Overlapping text: styles that only apply in dark mode can change layout too.

The report also notes whether the site responds to dark mode at all. If it doesn't, the dark screenshot simply shows the page as usual, and that's not counted against you: supporting dark mode is optional. Note that we emulate the standard media query that every browser exposes; browser-specific forced darkening, like Samsung Internet's, uses its own algorithm and isn't reproduced. Apple devices are checked in WebKit and Android devices in Chromium, so engine differences in page colors show up; native iOS form controls are only exact on a real iPhone.

How do I support dark mode properly?

Declare which schemes you support

The color-scheme property tells the browser that your page is designed for both schemes, so default backgrounds, form controls and scrollbars follow the theme:

<meta name="color-scheme" content="light dark">
:root { color-scheme: light dark; }

If your site is light-only, say so with color-scheme: light, so built-in controls don't turn dark inside a light page. Declaring a scheme also signals to browsers with automatic darkening that the page handles colors itself; how each browser uses that signal varies, so test the browsers your audience uses.

Use color variables

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #555555;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --text: #ececec;
    --muted: #a8a8a8;
  }
}
body { background: var(--bg); color: var(--text); }

Always set background and text color together. Most dark mode bugs come from setting one and inheriting the other.

Handle logos and images

Swap a dark logo for a light one with <picture>:

<picture>
  <source srcset="/logo-light.svg" media="(prefers-color-scheme: dark)">
  <img src="/logo-dark.svg" alt="Example Co">
</picture>

For inline SVG icons, use fill="currentColor" so they follow the text color. Photos usually don't need changes; very bright images can be toned down slightly with a filter if they feel glaring.

Avoid pure black and pure white

A very dark gray background with off-white text is easier on the eyes than #000 with #fff, and still has plenty of contrast. Check muted text, placeholders and disabled states, which tend to fall below 4.5:1 first.

Rethink shadows and borders

Drop shadows that separate cards from a white page barely show on a dark background. In dark mode, use slightly lighter surface colors for raised elements, or a subtle border, so cards, menus and dialogs remain distinguishable. Brand colors may need a lighter tint too: a saturated dark blue link that works on white can fall below the contrast threshold on a dark gray surface.

On iPhone vs Android

  • Safari only changes what your CSS tells it to. Without color-scheme, form fields and scrollbars stay light even in dark mode; with color-scheme: light dark and no colors of your own, Safari paints a dark default background and light text.
  • Chrome on Android follows the same rules, but some Chromium-based browsers and Samsung Internet can also darken pages automatically. Declaring color-scheme and styling dark mode yourself is the best way to keep control.
  • Browser toolbar color: a theme-color meta tag can take a media attribute, so you can give the browser bar a light and a dark color; how prominently it's used varies between browser versions.
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#121212" media="(prefers-color-scheme: dark)">

How do I check the fix?

Run the free check and open the dark mode screenshots in the report next to the normal ones. Any contrast problems in dark mode are listed with the elements highlighted. On your own phone you can switch the system appearance and reload the page; on a desktop, browser dev tools can emulate prefers-color-scheme, though device emulation in Chrome uses Chromium even when you pick an iPhone. If your visitors use Samsung phones, also try Samsung Internet's own dark mode on a real device. See testing on Android for more.

Frequently asked questions

Does my website need to support dark mode?

No. A site that stays light in dark mode is perfectly acceptable. What matters is that whatever the visitor sees is readable, so check that nothing turns half-dark with poor contrast.

What does the color-scheme meta tag do?

It tells the browser which color schemes the page supports, so default backgrounds, form controls and scrollbars match. Use content="light dark" if you style both, or "light" for a light-only site.

Why does my site look different in Samsung Internet dark mode?

Samsung Internet can darken pages with its own algorithm when its dark mode is on, even if the site has no dark styles. Results vary by version and settings, so test on a real device and provide your own dark styles if the automatic result looks wrong.

Sources

  1. MDN: prefers-color-scheme
  2. MDN: color-scheme
  3. web.dev: Improve dark mode default with color-scheme
  4. WebKit blog: Dark Mode Support in WebKit

Related guides