CSS Academy · Lesson

color-scheme Property

Use the color-scheme property to inform the browser which themes an element supports.

Lesson 3 of 412 steps

color-scheme Property is a free CSS Academy lesson on CoddyKit. This is lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, and your progress syncs across the web and the CoddyKit app. The CSS Academy course includes 4 lessons in total.

What is color-scheme?

The color-scheme property tells the browser which color schemes an element (or the page) supports. The browser then uses this information to style its own UI elements — scrollbars, form controls, checkboxes, input borders — to match the requested scheme.

color-scheme Values

Accepted values:

  • normal: element uses the document default
  • light: element supports light scheme only
  • dark: element supports dark scheme only
  • light dark: supports both; browser picks based on preference
  • dark light: prefers dark; falls back to light

Browser UI Elements

The browser automatically styles these elements according to color-scheme:

  • Scrollbars
  • Input fields, textareas, select dropdowns
  • Checkboxes, radio buttons
  • Range sliders
  • Date/time pickers

Setting on html Element

Setting color-scheme on the root element changes the entire page's system UI rendering:

<input type="checkbox" /> <select><option>A</option><option>B</option></select>

Meta Tag Equivalent

You can also declare color-scheme in HTML as a meta tag for earlier application (before CSS loads):

<pre class="code-sample">&lt;meta name="color-scheme" content="light dark"&gt;</pre>

Dark Mode Without Custom Colors

A minimal dark mode: set color-scheme: dark and let the browser handle form elements and scrollbars automatically:

<p>Native form controls and page background adapt to dark automatically.</p>
<input type="text" placeholder="Native input" />

Combining with prefers-color-scheme

Use prefers-color-scheme to detect preference and set both your custom tokens AND the color-scheme property together:

<div class="demo">Themed via variables + color-scheme</div>

Scoped color-scheme

Apply color-scheme to specific elements to create isolated light islands in a dark page:

<div class="light-widget">Always-light widget<br/><input type="date" /></div>

Forced Colors / Windows High Contrast

The forced-colors media query detects Windows High Contrast Mode. Use color-scheme and forced-colors together for comprehensive accessibility support.

<div class="card">Card respects forced-colors mode</div>

system-color Keywords

When forced-colors is active, use CSS system color keywords that map to the user's accessible color palette:

<button>System-styled button</button>

Quick Check

What CSS behavior does setting color-scheme: dark on the html element enable?

Recap

color-scheme instructs the browser how to style its own UI controls for an element or page. Use color-scheme: light dark globally to enable automatic native UI adaptation. Combine with CSS custom properties for a complete dark mode implementation. Use the meta tag for early application before CSS loads.

Free to start

Learn CSS with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
40
Lessons
159

Frequently Asked Questions

Is the “color-scheme Property” lesson free?

Yes — the full text of “color-scheme Property” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO. The CSS Academy course includes 4 lessons in total.

What will I learn in “color-scheme Property”?

Use the color-scheme property to inform the browser which themes an element supports. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.

How long does the “color-scheme Property” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. prefers-color-scheme Media Query
  2. CSS Variables for Theming
  3. color-scheme Property
  4. Automatic and Manual Dark Mode Toggle
← Back to CSS Academy