---
source: https://iinventedlight.com/library/notes/css-prefers-color-scheme.md
title: "prefers-color-scheme: style a page for light or dark mode"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (web.dev); CC-BY-4.0 (web.dev); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: web.dev, prefers-color-scheme: Hello darkness, my old friend; web.dev, Theming. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-24
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-24
as_of: 2026-11-24
confidence: medium
untested: "Not reproduced (2026-11-24). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: css-prefers-color-scheme"
tags: [css, color-scheme, dark-mode, media-queries, theming]
client: Librarian
sources:
  - id: S1
    title: "prefers-color-scheme: Hello darkness, my old friend"
    publisher: web.dev
    url: https://web.dev/articles/prefers-color-scheme
    accessed: 2026-11-24
    license: "CC-BY-4.0"
  - id: S2
    title: "Theming"
    publisher: web.dev
    url: https://web.dev/learn/design/theming
    accessed: 2026-11-24
    license: "CC-BY-4.0"
---
# prefers-color-scheme: style a page for light or dark mode
**Answer:** A light or a dark color palette can be a user preference on many operating systems.

## The media query

Authors use media queries to test values or features of the user agent or display device.

The test is independent of the document being rendered.

Those queries go in a CSS media rule so styles apply only in some conditions.

User preference media features arrived in Media Queries Level 5.

Sites can detect the user's preferred way to display content.

## Telling the browser

Optimizing for the user's theme preferences is a good idea.

On the html element, the color-scheme property can declare light and dark support.

light and dark are the usual values for color-scheme.

A theme color can also be specified in the document head.

## See also

- [css-color](https://iinventedlight.com/library/notes/css-color/)
- [css-media-queries](https://iinventedlight.com/library/notes/css-media-queries/)
- [css-custom-properties](https://iinventedlight.com/library/notes/css-custom-properties/)

## Claims

- id: C1
  claim: Media queries test features of the user agent or display.
  source: S1
  evidence: "test and query values or features of the user agent or display device"

- id: C2
  claim: User preference media features detect how the user wants content shown.
  source: S1
  evidence: "detect the user's preferred way to display content"

- id: C3
  claim: Operating systems let users prefer a light or dark palette.
  source: S2
  evidence: "a preference for a light or a dark color palette"

- id: C4
  claim: The color-scheme property can declare support for light and dark.
  source: S2
  evidence: "color-scheme: light dark"

## Sources

- [S1] prefers-color-scheme: Hello darkness, my old friend. web.dev. https://web.dev/articles/prefers-color-scheme . License: CC-BY-4.0. Accessed 2026-11-24.

- [S2] Theming. web.dev. https://web.dev/learn/design/theming . License: CC-BY-4.0. Accessed 2026-11-24.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, prefers-color-scheme: Hello darkness, my old friend; web.dev, Theming. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
