System Colors and Theme Support
You'll learn how CSS system colors let your designs automatically match a user's operating system appearance and dark mode preferences.
What Are System Colors?
System colors are special CSS color keywords that reference colors from the user's operating system or browser theme. Think of them like borrowing your visitor's own color palette rather than forcing your own. When someone has dark mode enabled on their phone or computer, system colors automatically adapt to respect that choice.
Why This Matters
Modern operating systems let users choose light or dark themes. System colors help your website feel native and comfortable by matching those preferences. Instead of blinding someone with a white background at midnight, your site can automatically switch to darker tones.
Common System Color Keywords
CSS provides keywords that tap into the OS theme:
Canvas— the default background color for contentCanvasText— the default text color on CanvasLinkText— the color used for hyperlinksButtonFace— the background color of buttonsButtonText— the text color on buttons
These keywords adapt automatically. If a user switches from light to dark mode, Canvas might change from white to dark gray, and CanvasText from black to light gray — with zero extra code from you.
Simple Example
body {
background-color: Canvas;
color: CanvasText;
}
a {
color: LinkText;
}
This respects whatever theme the user has chosen system-wide.
The Analogy
It's like wearing clothes that match the season automatically — your website "dresses" appropriately for light or dark environments without you manually creating separate stylesheets.
Key Takeaway: System colors are CSS keywords that automatically adapt to the user's OS theme preferences, creating more accessible and comfortable experiences across light and dark modes.