Design, UX & content

Designing websites for dark mode

Design for dark mode by following the visitor's system setting with the prefers-color-scheme media feature, declaring color-scheme so browser controls match, and building a separate dark palette that you test against WCAG contrast ratios. Dim photos slightly, provide logo and icon versions that work on dark backgrounds, and load the right theme before the page paints so visitors never see a bright flash.

By Tcom Consultants · Updated · 5 min read · 5 sources

Agent network illustration for Designing websites for dark mode

How dark mode on the web works

A website supports dark mode when it detects the visitor's system preference and switches to a dark colour palette designed for it. Browsers expose that setting through the prefers-color-scheme media feature, which reports light or dark. Your stylesheet uses it to swap colours, and the color-scheme property tells the browser to style its own controls to match. Good dark mode is a second design with its own tested colours.

Plenty of people now run their phones and laptops in dark mode all day. A site that stays bright white at night can feel jarring, and a poorly made dark theme with grey-on-grey text is worse. The steps below cover both the design and the build.

Decide how the theme gets chosen

Follow the system setting by default. Google's web.dev article on prefers-color-scheme recommends respecting the operating system preference and optionally letting visitors override it with a toggle. If you add a toggle, remember the choice so it survives a page change, and offer three states: light, dark and match system.

Declare color-scheme first

The color-scheme property tells the browser which themes your page supports, so it can render form fields, scrollbars and other built-in elements in matching colours. Set it on the root element with the value light dark. Without it, you can end up with a dark page full of bright white input boxes.

Use light-dark() to keep stylesheets small

The CSS light-dark() function takes two colours and returns the first in light mode and the second in dark mode, without a separate media query. MDN lists it as widely available across browsers since May 2024, and notes it only works when color-scheme is set to light dark. Pair it with named colour variables such as surface, text and accent so the meaning stays the same in both themes.

Build a dark palette that works

Inverting your light theme produces harsh results. Build the dark palette as its own set of decisions.

Start with three or four surface levels: the page background, cards, raised panels and overlays. In a light theme, depth often comes from shadows. In a dark theme, shadows barely show, so raised elements usually get a slightly lighter surface colour instead. Then set text colours for primary, secondary and disabled states, and finally adjust your accent colour until buttons and links pass contrast on every surface they sit on.

ElementLight theme habitDark theme approach
BackgroundWhiteVery dark grey or a dark tint of your brand colour
Body textNear blackOff-white, slightly softer than pure white
Brand accentFull saturationOften a lighter, less saturated version for contrast
Borders and dividersLight greySubtle lighter lines, or spacing instead of lines
ShadowsDrop shadows for depthLighter surfaces for raised elements

web.dev suggests avoiding pure white text on dark backgrounds, because it can appear to glow and bleed. A slightly off-white reads more comfortably for long paragraphs.

Keep saturated colours for small accents. Large blocks of bright brand colour on a dark page are tiring to look at, and they pull attention away from the content. If your brand relies on a strong colour, use it for buttons, links and highlights, and let the dark surfaces carry the rest of the page.

Check contrast in both themes

The W3C's guidance on contrast (minimum) asks for a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. That applies to your dark theme as much as your light one. Brand colours that pass on white often fail on dark grey, especially reds and blues, so test every text and button colour pair in a contrast checker.

Contrast checks people forget

  • Placeholder text and helper text inside form fields.
  • Links inside body text, which need to stand out from surrounding text too.
  • Focus outlines, which can disappear against dark surfaces.
  • Text on top of images or video in hero sections.
  • Error and success messages that rely on red and green.

Handle images, logos and icons

Photos can look too bright in a dark interface. web.dev describes dimming photos slightly in dark mode with a CSS filter, and swapping major images with the picture element when a dedicated dark version works better. Compressed modern formats keep both versions light; see our guide to image optimization and WebP.

  1. Create a logo version for dark backgrounds, often a light or reversed lockup.
  2. Use SVG icons that inherit the text colour so they switch automatically.
  3. Avoid transparent PNG logos with dark text that vanish on dark pages.
  4. Check charts and diagrams, which often hard-code white backgrounds.

Your logo is part of your identity, so plan the dark version when the brand is created. Our guide to building a brand identity for a small business covers logo variations.

Avoid the flash and test properly

A bright flash before the dark theme loads is the most common complaint about dark mode on websites. Put the theme colours in CSS that loads in the head, and if you use a saved toggle preference, apply it with a tiny inline script before the page renders. web.dev also advises against making visitors download CSS for a theme they are not using in the critical rendering path.

Test every page template in both themes on a real phone at night. Look at forms, tables, embedded maps and third-party widgets, which often ignore your theme. Transitions between themes should be quick and simple; our guide to motion design on websites explains how to keep animation light. Dark mode is one of several current design shifts covered in our web design trends for 2026.

How Tcom can help

We build sites with tested light and dark themes as part of our website development service, and we keep structured data and content identical across both, as described in our answer on schema markup for small businesses. See our work or contact us to add dark mode to your site.

Questions

Does dark mode affect SEO?

Not directly. Search engines read the same content in either theme. Dark mode matters for user comfort and accessibility, and a badly loaded theme can cause layout or rendering issues that hurt experience.

Should my site default to dark mode?

Usually not. Follow the visitor's system setting so each person sees the theme they chose, and offer a toggle if your audience asks for one.

Does dark mode save battery?

It can on some screen types, but the effect depends on the device. Design dark mode for comfort and preference rather than promising battery savings.

Do emails need a dark mode design too?

Many email apps apply their own dark mode and may change your colours. Test campaigns in the main email apps and use logos that work on both light and dark backgrounds.

Sources

  1. prefers-color-scheme MDN Web Docs
  2. color-scheme MDN Web Docs
  3. light-dark() MDN Web Docs
  4. prefers-color-scheme: Hello darkness, my old friend web.dev (Google)
  5. Understanding Success Criterion 1.4.3: Contrast (Minimum) W3C Web Accessibility Initiative

Sources checked 23 November 2026.