CSS color-scheme Property

Beginner
5 examples
Updated: Nov 2026

Definition and Usage

The color-scheme property tells the browser which light and dark schemes an element can render correctly. The browser can then match built-in controls, scrollbars, and default canvas colors to the chosen scheme.

Not a complete theme.

Declare your component colors too. This property mainly coordinates browser-provided UI.

CSS Syntax

syntax.css
color-scheme: normal | light | dark | light dark | only light;

Property Values

ValueEffectTry it
normalNo preferred scheme is declaredTry it
lightSupport a light color schemeTry it
darkSupport a dark color schemeTry it
light darkSupport both, preferring the first if no preference existsTry it
only lightPrevent browser overrides to a dark schemeTry it

CSS Examples

Follow the user preference

Advertise support for both schemes on the root element.

root.css
:root { color-scheme: light dark; }
Try It Yourself

Dark component

Give one subtree dark browser controls.

panel.css
.dark-panel {
  color-scheme: dark;
  background: #111827;
  color: #f8fafc;
}
Try It Yourself

Force a light widget

only light keeps a light control inside otherwise dark content.

light.css
.payment-form { color-scheme: only light; }
Try It Yourself

Browser Support

color-scheme controls browser-rendered UI.

✓ Baseline · Widely available

color-scheme

Supported in current Chrome, Edge, Firefox, Safari, and Opera.

96% Modern browsers
Google Chrome 81+
Full support
Mozilla Firefox 96+
Full support
Apple Safari 13+
Full support
Microsoft Edge 81+
Full support
color-scheme Widely supported

Bottom line: Safe for current browsers. Always test your own foreground and background colors in every declared scheme.

Frequently Asked Questions

It lets the browser draw built-in UI such as form controls, scrollbars, and default canvas colors for supported light or dark schemes.
No. It changes browser-provided UI and defaults. You still need your own colors for custom components.
The element supports both schemes. The browser chooses one from the user's preference and other page settings.
Yes. Set it on a component to change supported built-in controls inside that subtree.
Current Chrome, Edge, Firefox, Safari, and Opera support color-scheme.

Next: column-count

Flow content into multiple columns.

column-count tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful