# How to screenshot a website in dark mode

> How to capture any site in dark or light mode, the three ways a site switches its theme, why a page ignores your dark setting, and the fix for each case.

Explainer by Serghei Pogor, founder of CurlShot (https://curlshot.com/about/serghei-pogor). Published 21 October 2026. Page for people: https://curlshot.com/blog/dark-mode-screenshots

To screenshot a website in dark mode, make the browser report a dark preference, then capture as usual: switch the operating system to dark, emulate prefers-color-scheme: dark in the browser's developer tools, or set colorScheme: 'dark' in Playwright. With CurlShot, add dark_mode=true to the request. This works on every site whose CSS follows the prefers-color-scheme media query. A site that changes theme only with its own button stays light until you press that button, send its cookie or set its class with a script.

## Key facts

- A site turns dark in one of 3 ways: the prefers-color-scheme media query, a class or attribute on the html element set by its own button, or not at all.
- Emulation flips only the media query. It cannot press a theme button, and it does not darken a site that has no dark theme.
- prefers-color-scheme has 2 values, light and dark, and has worked across browsers since January 2020 (MDN).
- The color-scheme property (across browsers since January 2022) makes form controls, scrollbars and the page canvas match the theme.
- light-dark() holds both colours in one declaration and has been Baseline since May 2024; it needs color-scheme: light dark.
- A capture tool is always a first-time visitor: a theme you saved in localStorage or a cookie in your own browser is not there.

## One page, day and night

The page opens with one miniature web page drawn twice, in its light and its dark theme, and a divider to wipe between them. The layout is identical in both: only colours change, plus the things a theme can break (images, logos, form controls, scrollbars).

## How a website decides to be dark: the signal path

A dark preference travels from the operating system to the page in five steps, and a dark screenshot fails when the signal is lost on the way.

1. **Operating system.** The visitor picks light or dark once, in the system settings.
2. **Browser.** The browser passes the setting on to every page it opens. [1] *Where a capture tool steps in:* DevTools, Playwright, Puppeteer and screenshot APIs override the setting here. That is emulation.
3. **Media query.** `(prefers-color-scheme: dark)` becomes true or false inside the page. [1]
4. **The site’s CSS.** Rules inside the media query, or `light-dark()` values, swap the colours. [4] *Where it breaks:* No dark rules, or rules that follow a class on `<html>` and not the media query: the signal arrives and nothing listens.
5. **The painted page.** The browser draws the page, plus its own parts: form controls, scrollbars, the canvas behind the page. [2] *Where it breaks:* Without `color-scheme`, the browser’s own parts stay light on a dark page.

### The three switches

| Switch | How it works | Flipped by | Remembered in | Can a capture tool flip it? |
| --- | --- | --- | --- | --- |
| The media query | The site’s CSS asks `prefers-color-scheme` and changes its colours when the answer is dark. [1] | The operating system setting, or a browser setting, on the visitor’s device. | Nowhere on the site. It is read fresh on every visit. | Yes. Emulation sets the answer directly, with no change to the machine that takes the screenshot. |
| A class or attribute on `<html>` | The site’s own theme button runs a script that sets something like `class="dark"` or `data-theme="dark"`, and the CSS follows that. | The visitor, by pressing the site’s button. | In that browser only: localStorage or a cookie for that site. | Not by emulation. Press the button, send the cookie, or set the class with a script. Many of these sites start from the media query until a visitor chooses, and a capture tool is always a first-time visitor, so try emulation first. |
| No dark theme at all | The site has one set of colours. A browser may darken it by itself: Chrome on Android introduced Auto Dark Theme in Chrome 96 as an origin trial, which applies a generated dark theme to light sites. [5][2] | Nothing on the site. Only a browser feature that repaints it. | Not applicable. A site opts out of forced darkening with `color-scheme: only light`. | No. The page looks the same with a dark preference. The only way to a dark screenshot is to repaint it with your own CSS. |

## Why did my dark screenshot come out light?

| Symptom | Cause | Fix |
| --- | --- | --- |
| The whole page stays light | The dark theme is switched by a class or attribute on `<html>` that the site’s own button sets. The CSS never asks the media query. Or the site has no dark theme. | Press the site’s theme button before the capture, or set the class yourself with a script. If there is no dark theme, only your own CSS can darken the page. |
| Dark in your browser, light in the capture | You once chose dark on that site, and it saved the choice in localStorage or a cookie in your browser. A capture tool starts with empty storage, so the site treats it as a new visitor. | Send the cookie the site uses for its theme, or set the class with a script. Sites that fall back to the media query for new visitors only need emulation. |
| Light, or half light, on a site that turns dark a moment later | The page paints once in its default colours and a script switches the theme afterwards. A screenshot taken in that gap records the flash. | Capture later: wait for an element or class that only exists in the dark theme, or add a short delay. Site owners: put `<meta name="color-scheme">` in the head before any CSS and set the theme class in an inline script in the head. [2][3] |
| A bright rectangle glares in a dark page | A photo, chart or screenshot with a white background has no dark variant. An image does not change with the theme unless the site supplies a second file. | Site owners: add a dark file with `<picture>` and `<source media="(prefers-color-scheme: dark)">`, or give `light-dark()` two images in CSS. For someone else’s page, soften images with a CSS filter of your own. [12][4] |
| A logo or icon disappears | A transparent PNG or SVG drawn in dark ink now sits on a dark background. | Supply a light variant the same way as for photos, draw inline SVG icons with `currentColor` so they take the text colour, or put a light plate behind the image. [12] |
| Text fields, checkboxes and scrollbars stay light | The page does not declare `color-scheme`, so the browser keeps drawing its own parts in light colours: form controls, scrollbars and the canvas behind the page. | Site owners: `:root { color-scheme: light dark; }`. For a capture of someone else’s page, add `:root { color-scheme: dark; }` as custom CSS. [2] |
| A transparent screenshot of a dark page is unreadable in a document | A capture with a transparent background drops the dark backdrop but keeps the light text, which then lands on the white page of the document. | Keep the background when you capture a dark theme, or place the image on a dark surface. |

## How to turn on dark mode by hand

### In one browser tab, with developer tools

Only the open tab turns dark. Nothing else on the computer changes.

| Where | Path | Note |
| --- | --- | --- |
| Chrome DevTools | Rendering tab > Emulate CSS media feature prefers-color-scheme > prefers-color-scheme: dark [6][7] | Open the Rendering tab from More options > More tools > Rendering, or press Ctrl+Shift+P (Cmd+Shift+P on a Mac), type "rendering" and choose Show Rendering. |
| Firefox DevTools | Page Inspector > Rules view toolbar > the two buttons that enable the light and the dark preference [8] | Selecting one button deselects the other. With neither selected, emulation is off. |
| Safari Web Inspector | Elements tab > Override user preferences > color scheme [9] | The same popover overrides reduced motion and increased contrast. |

### For the whole device, in system settings

Every app and every site that follows the setting turns dark.

| Where | Path | Note |
| --- | --- | --- |
| macOS | System Settings > Appearance > Light, Dark or Auto [13] | Auto follows the Night Shift schedule. |
| Windows | Settings > Personalization > Colors > Choose your mode > Light, Dark or Custom [15] |  |
| iPhone and iPad | Settings > Appearance > Dark [14] | In iOS 26 and earlier the options are under Settings > Display & Brightness. |
| Android | Settings > Display > Dark theme [16] | On some devices the menu is called Display & touch. |

Once the page is dark, take the screenshot the usual way: see [how to take a full page screenshot on every device](https://curlshot.com/blog/full-page-screenshot-every-device).

## The CSS for a site that supports both themes

A site supports both themes correctly when it declares `color-scheme`, follows the media query, and lets its own theme button override both.

The classic way, with custom properties and the media query:

```css
:root {
  color-scheme: light dark;
  --page: #ffffff;
  --text: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #121212;
    --text: #ededed;
  }
}

body {
  background: var(--page);
  color: var(--text);
}
```

The short way, with `light-dark()`:

```css
:root {
  color-scheme: light dark;
}

body {
  background: light-dark(#ffffff, #121212);
  color: light-dark(#1a1a1a, #ededed);
}

/* A theme button only has to set the scheme. */
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark']  { color-scheme: dark; }
```

And in the head of the document:

```html
<head>
  <!-- Before any CSS, so the first paint is already right. -->
  <meta name="color-scheme" content="light dark" />
  <link rel="stylesheet" href="/styles.css" />
</head>
```

| Feature | What it does | Browser support (MDN) |
| --- | --- | --- |
| `prefers-color-scheme` | Media feature that tells CSS whether the visitor asked for a light or a dark theme. Its values are `light` and `dark`; no stated preference counts as `light`. | Widely available, across browsers since January 2020 [1] |
| `color-scheme` | Property that says which schemes an element can be drawn in. The browser then matches the canvas, scrollbars and form controls. | Widely available, across browsers since January 2022 [2] |
| `<meta name="color-scheme">` | The same statement for the whole document, readable before any CSS has loaded. | MDN gives it no separate date; it takes the values of `color-scheme` [3] |
| `light-dark()` | Function that takes two colours or two images and returns the one for the active scheme. Needs `color-scheme: light dark`. | Baseline 2024, newly available since May 2024 [4] |

### Emulating dark mode in Playwright and Puppeteer

Playwright takes a `colorScheme` option with the values `light`, `dark` and `no-preference` [10]. Puppeteer takes a list of media features [11].

```js
// Playwright: for every page of a context
const context = await browser.newContext({ colorScheme: 'dark' })

// Playwright: on a page that is already open
await page.emulateMedia({ colorScheme: 'dark' })

// Puppeteer
await page.emulateMediaFeatures([
  { name: 'prefers-color-scheme', value: 'dark' },
])
```

## Light and dark pairs

A light and dark pair is two screenshots of the same page that differ in the theme and in nothing else. People make them for:

- Documentation that shows each reader the screenshot matching their theme
- App store and marketplace listings that present both looks
- Design reviews, where the two themes are checked against each other
- Release checks that a change did not break the theme nobody on the team uses

| Keep the same | Why | Option |
| --- | --- | --- |
| Same window | A different width reflows the page and the two images no longer line up. | `viewport_width`, `viewport_height` |
| Same pixel density | The images must have the same pixel size to sit side by side. | `device_scale_factor` |
| Same scroll position | Capture both from the top, or both as full pages. | `full_page` on both, or on neither |
| Stopped animations | A carousel or a fade caught at two different moments looks like a theme difference. | `reduced_motion=true` |
| No overlays | A cookie banner that shows in one capture and not the other spoils the pair. | `block_cookie_banners=true` |
| Only the theme differs | Say light out loud as well, so both requests read the same. | `dark_mode=false`, then `dark_mode=true` |

```bash
SHOT="https://curlshot.com/api/v1/screenshot?access_key=YOUR_ACCESS_KEY\
&url=https://example.com\
&viewport_width=1280\
&viewport_height=800\
&device_scale_factor=2\
&reduced_motion=true\
&block_cookie_banners=true"

curl "$SHOT&dark_mode=false" --output light.png
curl "$SHOT&dark_mode=true"  --output dark.png
```

To show each reader the screenshot that matches their theme, put both files in a `<picture>` element with `<source srcset="dark.png" media="(prefers-color-scheme: dark)">` before the light `<img>` [12].

## What dark_mode does in CurlShot

The `dark_mode` option of CurlShot is emulation of the media query: with `dark_mode=true` the browser that renders your page reports `prefers-color-scheme: dark`, and with `dark_mode=false` (the default) it reports `light`. It asks, it does not repaint. It does not force-darken a site without a dark theme, and it cannot flip a theme that only changes with the site's own button. There is no option that writes localStorage before the page loads. For those sites, combine it with one of these:

| Option | What it does | Use it when |
| --- | --- | --- |
| `click` | Clicks the first element that matches a CSS selector. | the site has a visible theme button. One click per request. |
| `cookies` | Sets cookies before the page loads. | the site remembers the theme in a cookie and you know its name and value. |
| `scripts` | Runs your JavaScript on the loaded page, just before the capture. | the theme is a class or attribute on `<html>`: set it directly. |
| `styles` | Adds your CSS on top of the site’s own. | the site has no dark theme, or you need `:root { color-scheme: dark; }`. |
| `wait_for_selector, delay` | Hold the capture until an element is visible, or for a number of seconds. | the theme arrives a moment after the first paint. |

A request for a site whose theme is a class on `<html>`:

```bash
curl -X POST "https://curlshot.com/api/v1/screenshot" \
  -H "X-Access-Key: YOUR_ACCESS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "dark_mode": true,
    "scripts": "document.documentElement.classList.add(\"dark\")"
  }' \
  --output dark.png
```

More: [dark mode screenshot tool](https://curlshot.com/tools/dark-mode-screenshot), [dark mode and emulation](https://curlshot.com/docs/dark-mode-and-emulation), [custom CSS, JavaScript and clicks](https://curlshot.com/docs/customize).

## Glossary

- **Dark mode:** A setting of a device or an app that asks for light text on dark backgrounds. A website shows a dark theme only if its authors wrote one.
- **Colour scheme:** The pair of looks a page can have: light or dark. CSS uses the American spelling, `color-scheme`.
- **prefers-color-scheme:** The CSS media feature that reports whether the visitor asked for a light or a dark theme, through the operating system or the browser.
- **color-scheme:** The CSS property, and the meta tag of the same name, with which a page says which schemes it supports, so the browser draws its own parts to match.
- **light-dark():** A CSS function that holds a light value and a dark value and returns the one for the active colour scheme.
- **Theme toggle:** A button on a site that switches its theme with a script and remembers the choice in localStorage or a cookie.
- **Emulation:** A browser pretending to have a setting it does not have. Emulating a dark preference changes what the media query answers, and nothing else.
- **Forced dark:** A browser darkening a page that has no dark theme, by generating one. Chrome calls its version Auto Dark Theme.
- **Flash of the wrong theme:** The moment a page shows its default colours before a script applies the saved theme. A capture can land in it.

## Questions

### How do I take a screenshot of a website in dark mode?

Make the browser report a dark preference, then take the screenshot. By hand: switch the operating system to dark, or in Chrome DevTools open the Rendering tab and set "Emulate CSS media feature prefers-color-scheme" to dark. In code: colorScheme: 'dark' in Playwright, emulateMediaFeatures in Puppeteer, or dark_mode=true in a CurlShot request.

### Why does a website ignore my dark mode setting?

Either the site has no dark theme, or its dark theme is switched by its own button and not by the prefers-color-scheme media query. In the second case the site sets a class or attribute on the html element with a script and remembers the choice in localStorage or a cookie, so the system setting is never asked.

### Why is a site dark in my browser but light in a screenshot tool?

Because your browser remembers a choice you made on that site, in localStorage or a cookie, and a screenshot tool starts with empty storage like a first-time visitor. Send the cookie the site uses, press its theme button, or set the class on the html element with a script before the capture.

### Can I force dark mode on a website that has no dark theme?

Not by emulation: a dark preference changes nothing on a site with no dark styles. Some browsers can generate a dark version by themselves (Chrome on Android calls it Auto Dark Theme), and you can add your own CSS before a capture, but the result is a repaint, not the site's design.

### How do I screenshot a website in light mode when it defaults to dark?

Emulate the light preference: prefers-color-scheme: light in developer tools, or colorScheme: 'light' in Playwright. In CurlShot, dark_mode is false by default, so the rendering browser always reports light unless you ask for dark. A site whose only design is dark stays dark.

### What is the difference between prefers-color-scheme and color-scheme?

prefers-color-scheme is a media feature: it lets the CSS of a page read what the visitor asked for. color-scheme is a property and a meta tag: it lets the page tell the browser which schemes it supports, so the browser draws form controls, scrollbars and the canvas to match. A complete dark theme uses both.

### How do I make matching light and dark screenshots of the same page?

Capture twice with everything identical except the theme: the same viewport width and height, the same pixel density, the same scroll position or full page setting, animations stopped and overlays blocked. Then change only the colour scheme between the two captures.

## Sources

1. MDN Web Docs, "prefers-color-scheme": https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme (checked 11 October 2026)
2. MDN Web Docs, "color-scheme": https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme (checked 11 October 2026)
3. MDN Web Docs, "<meta name="color-scheme">": https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name/color-scheme (checked 11 October 2026)
4. MDN Web Docs, "light-dark()": https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark (checked 11 October 2026)
5. Chrome for Developers, "Auto Dark Theme": https://developer.chrome.com/blog/auto-dark-theme (checked 11 October 2026)
6. Chrome for Developers, "Emulate CSS media features": https://developer.chrome.com/docs/devtools/rendering/emulate-css (checked 11 October 2026)
7. Chrome for Developers, "Rendering tab overview": https://developer.chrome.com/docs/devtools/rendering (checked 11 October 2026)
8. Firefox Source Docs, "Examine and edit CSS": https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/examine_and_edit_css/index.html (checked 11 October 2026)
9. WebKit, "Web Inspector: Elements tab": https://webkit.org/web-inspector/elements-tab/ (checked 11 October 2026)
10. Playwright, "Emulation": https://playwright.dev/docs/emulation (checked 11 October 2026)
11. Puppeteer, "Page.emulateMediaFeatures() method": https://pptr.dev/api/puppeteer.page.emulatemediafeatures (checked 11 October 2026)
12. web.dev, "prefers-color-scheme: Hello darkness, my old friend": https://web.dev/articles/prefers-color-scheme (checked 11 October 2026)
13. Apple Support, "Use a light or dark appearance on your Mac": https://support.apple.com/guide/mac-help/use-a-light-or-dark-appearance-mchl52e1c2d2/mac (checked 11 October 2026)
14. Apple Support, "Use Dark Mode on your iPhone and iPad": https://support.apple.com/en-us/108350 (checked 11 October 2026)
15. Microsoft Support, "Change colors in Windows": https://support.microsoft.com/en-us/windows/change-colors-in-windows-d26ef4d6-819a-581c-1581-493cfcc005fe (checked 11 October 2026)
16. Android Help, "Change to dark theme or adjust the color scheme on your Android device": https://support.google.com/android/answer/9730472 (checked 11 October 2026)

## Go deeper

- [Dark mode screenshot tool](https://curlshot.com/tools/dark-mode-screenshot)
- [Dark mode and emulation](https://curlshot.com/docs/dark-mode-and-emulation)
- [Custom CSS, JavaScript and clicks](https://curlshot.com/docs/customize)

## Read next

- [Why website screenshots look wrong, and the fixes](https://curlshot.com/blog/why-website-screenshots-look-wrong.md): A field guide to 11 ways a website screenshot goes wrong, from blank lazy images to cookie banners and cut-off pages, with the cause and the fix for each.
- [Visual regression testing, explained in pictures](https://curlshot.com/blog/visual-regression-testing-guide.md): How screenshot comparison works, why visual tests go flaky and how to fix each cause, the tools, and a set-up checklist with a Playwright example.
- [Screenshot API vs headless browser: the real cost](https://curlshot.com/blog/screenshot-api-vs-headless-browser.md): A cost calculator with every assumption editable, the hidden work behind headless Chrome, and an honest checklist for build or buy.
