In short
- Dark mode is a colour scheme with light text on a dark background, either as the site's only look or as an option.
- Good dark design avoids pure black and pure white. Dark greys and off-whites are far easier on the eye.
- Depth comes from lighter surfaces, not shadows, and bright brand colours need toning down.
- CSS can follow the visitor's device setting automatically with
prefers-color-scheme. - A dark theme is a second design to test and maintain. It is worth it for some sites and unnecessary for others.
Dark mode has gone from a preference of programmers to a setting on every phone and computer. Many people now keep their devices dark all day, and they notice when a website ignores that and fills the screen with white. Others choose a dark design for its own sake, because it makes photographs glow and gives a site a distinctive character.
This site is dark by design, so the advice below comes from building and maintaining one. Dark mode is easy to do badly. Done well, it takes more care than a light design, not less.
Two Meanings of Dark Mode
The phrase covers two different decisions, and it helps to separate them.
| Approach | What it means | Suits |
|---|---|---|
| A dark design | The site has one look, and it is dark. | Portfolios, studios, entertainment, technology and brands that want drama |
| A dark theme | The site has a light and a dark version and switches between them. | Applications, documentation, long-form reading and sites people use for hours |
A dark design is a brand decision, like choosing a typeface. A dark theme is a feature, offered so that visitors can match the site to their device or their surroundings. The design principles are the same for both. The engineering is only needed for the second.
Does Dark Mode Help?
The claims made for dark mode are stronger than the evidence, so it is worth being accurate about them.
- Comfort in low light. A dark screen is less glaring in a dim room. That is a real benefit, and the main reason people choose it.
- Battery life. On phones and laptops with OLED screens, dark pixels use less power. On the LCD screens many devices still have, it makes little difference.
- Readability. For long passages of text in good light, dark text on a light background is generally easier to read, and people with astigmatism often find that light text on dark appears to blur.
- Focus on images. Photographs, video and colourful graphics stand out strongly against a dark surround, which is why galleries and film sites favour it.
The fair conclusion is that neither is better. They suit different content, different surroundings and different people, which is the argument for following the visitor's preference where a site can.
Designing the Dark Palette
A dark theme is not a light theme inverted. Flipping every colour produces harsh contrast, garish accents and shadows that make no sense. The palette has to be designed.
- Avoid pure black. A very dark grey or a dark tinted neutral is softer, and it lets you place even darker shadows and edges on it.
- Avoid pure white text. Off-white on dark grey is comfortable. Pure white on pure black makes text appear to shimmer.
- Show depth with lightness. On a light page, raised things cast shadows. On a dark page shadows barely show, so raised surfaces such as cards and menus are made slightly lighter than the background.
- Tone down saturated colours. A vivid brand colour that works on white can vibrate against a dark background. Use a lighter, less saturated version on dark surfaces.
- Check contrast again. The same minimums apply, including 4.5 to 1 for body text. Muted grey text is where dark designs most often fail.
- Do not overshoot. Very high contrast everywhere is tiring. Reserve the brightest white for headings and key text.
| Role | Light theme | Dark theme |
|---|---|---|
| Page background | #ffffff | #14181f |
| Raised surface | #f4f6f8 | #1f2530 |
| Body text | #1c2430 | #e6eaf0 |
| Muted text | #55606e | #a3aebd |
| Accent | #0b6b5d | #4fd1c1 |
Our guide to website colour schemes explains how to build the palette these roles come from.
Following the Visitor's Preference
Every modern operating system lets people choose a light or dark appearance, and browsers pass that choice to websites. CSS reads it with the prefers-color-scheme media query. Combined with custom properties, a second theme is a second set of values.
:root {
color-scheme: light dark;
--background: #ffffff;
--surface: #f4f6f8;
--text: #1c2430;
--accent: #0b6b5d;
}
@media (prefers-color-scheme: dark) {
:root {
--background: #14181f;
--surface: #1f2530;
--text: #e6eaf0;
--accent: #4fd1c1;
}
}
body {
background: var(--background);
color: var(--text);
}The color-scheme property tells the browser that the page supports both, so that it draws scroll bars, form controls and other built-in elements to match. A newer function, light-dark(), lets you write both values in a single declaration, and it is supported in all current browsers.
:root {
color-scheme: light dark;
}
.card {
background: light-dark(#f4f6f8, #1f2530);
color: light-dark(#1c2430, #e6eaf0);
}Adding a Theme Toggle
Following the device setting is a good default, but some people want a site dark while their device is light, or the reverse. A toggle gives them the choice.
- Offer three states where you can: light, dark and match my device.
- Remember the choice, so that it holds on the next visit.
- Apply the saved theme before the page is drawn. If it is applied afterwards, the page flashes in the wrong theme on every load.
- Make the toggle a real button with a clear label, and announce its state to screen readers.
const saved = localStorage.getItem("theme");
if (saved) {
document.documentElement.dataset.theme = saved;
}
document.querySelector("#theme-toggle").addEventListener("click", () => {
const root = document.documentElement;
const next = root.dataset.theme === "dark" ? "light" : "dark";
root.dataset.theme = next;
localStorage.setItem("theme", next);
});The stylesheet then applies the dark values under a data-theme attribute on the root element as well as inside the media query, so that the visitor's own choice wins over the device setting.
Images, Logos and Details
- Logos. A dark logo vanishes on a dark background. Supply a light version, or an SVG whose colours follow the theme.
- Photographs. Bright images can glare on a dark page. Slightly reducing their brightness in the dark theme helps.
- Illustrations and icons. Anything drawn with a white background will show as a white box. Use transparent backgrounds.
- Shadows and borders. Replace shadows with subtle lighter borders or surfaces.
- Embedded content. Maps, videos and forms from other services may stay stubbornly light. Check them.
- Focus outlines and form fields. Make sure they remain clearly visible in both themes.
@media (prefers-color-scheme: dark) {
img:not([src$=".svg"]) {
filter: brightness(0.9);
}
}Does Your Website Need a Dark Theme?
Not necessarily. A second theme doubles the number of colour combinations to design, check for contrast and test, and every new component has to work in both. For a ten-page site for a local business, that effort is usually better spent on the content and the other items in our startup website checklist.
| A dark theme is worth it when | It can wait when |
|---|---|
| People use the site for long periods, as with software and dashboards | Visits are short and practical: find a number, check a price, make a booking |
| The audience is technical and expects it | The budget is limited and the content is more urgent |
| The content is read at night, such as documentation or long articles | The brand depends on a light, airy look |
| The colours are already defined as a small set of named values | Colours are scattered through the code and would need untangling first |
What every site should do is make a deliberate choice. If the site is light only, it should still set its colours explicitly, so that browsers and extensions which force a dark appearance do not produce unreadable combinations. Making either theme readable for everyone is part of web accessibility.
Common Dark Mode Mistakes
- Inverting the light theme. The colours need designing, not flipping.
- Pure black and pure white. The harshest possible combination.
- Grey text that fails contrast. Muted text needs checking more carefully on dark backgrounds.
- Vivid accents left unchanged. Saturated colours glow uncomfortably on dark.
- Forgetting the logo. And any image with a white box around it.
- A flash of the wrong theme. Applying the saved choice after the page has drawn.
- Testing only one theme. Whichever one the designer does not use will be the one with the bugs.
Putting It Into Practice
Reading about a technique is the easy part. Applying it to a real business, with real content and a launch date, takes judgement about what to use and what to leave out. DigitalPod is a UK-based design and web development studio that designs every site from a blank page and builds it by hand, so a technique is used because it helps the business and not because a template came with it. If you would like a website designer to handle it for you, startup website design is what we specialise in, websites start from £2,400 and our website redesign service brings an older site up to date.
Frequently Asked Questions
What is dark mode in web design?
Dark mode is a colour scheme that uses light text and elements on a dark background. A website can be dark as its only design, or it can offer light and dark themes and switch between them according to the visitor's device setting or their own choice.
Is dark mode better for your eyes?
It is more comfortable in dim surroundings, because the screen gives off less glare. In good light, dark text on a light background is generally easier to read for long passages, and some people, including many with astigmatism, find light text on dark harder to focus on. Neither is better for everyone.
Does dark mode save battery?
On devices with OLED screens, yes, because dark pixels draw less power. On LCD screens, which light the whole panel whatever is shown, the saving is negligible. It is a modest benefit for phone users and no reason on its own to redesign a site.
How do I add dark mode to a website?
Define the site's colours as CSS custom properties, then provide a second set of values inside a prefers-color-scheme: dark media query. That follows the visitor's device setting automatically. A toggle that stores the visitor's own choice can be added on top.
Should a business website have dark mode?
Only if it serves the visitors. Sites that people use for long periods, or at night, benefit most. For a small brochure site with short visits, a single well-designed theme, light or dark, is usually the better use of the budget.