---
title: "What is prefers-color-scheme?"
term: "prefers-color-scheme"
description: "prefers-color-scheme is a CSS media feature that websites use in media queries to detect whether a visitor's device is set to a light or dark color theme, so they can adjust their colors to match."
url: "https://glossary.io/prefers-color-scheme/"
published: "2026-11-22T20:42:33.999Z"
updated: "2026-11-22T20:42:33.999Z"
topics:
  - "Web development"
wikidata: "https://www.wikidata.org/wiki/Q106921139"
---

# What is prefers-color-scheme?

**Definition:** prefers-color-scheme is a CSS media feature that websites use in media queries to detect whether a visitor's device is set to a light or dark color theme, so they can adjust their colors to match.

A [CSS](https://glossary.io/css/) stylesheet can define default colors and then override them inside a media query for the dark value, or the reverse. Browsers read the setting from the operating system or from the browser's own theme. [JavaScript](https://glossary.io/javascript/) can check the same preference with the matchMedia method and react when the user switches themes.

Chrome, Firefox and Safari all added support in 2019, which made [dark mode](https://glossary.io/dark-mode/) for websites practical. Respecting the preference can make reading more comfortable for people who use dark mode, and pairing it with the color-scheme property tells the browser to style built-in elements such as form controls and scrollbars to match.

## prefers-color-scheme resources

- [Chrome, Firefox, and Safari now support dark mode for websites](https://coywolf.com/news/web-development/dark-mode/)

## Related terms

- [Dark mode](https://glossary.io/dark-mode/)
- [CSS](https://glossary.io/css/)
- [JavaScript](https://glossary.io/javascript/)

**Topic:** [Web development](https://glossary.io/topics/web-development/)

## Cite this definition

- APA: What is prefers-color-scheme? (2026, November 22). Glossary. https://glossary.io/prefers-color-scheme/
- MLA: “What Is prefers-color-scheme?” Glossary, Coywolf, 22 Nov. 2026, glossary.io/prefers-color-scheme/.
- Chicago: “What Is prefers-color-scheme?” Glossary. Coywolf. November 22, 2026. https://glossary.io/prefers-color-scheme/.

Published November 22, 2026.
