Theming Websites with CSS
Techniques for building switchable themes with custom properties, design tokens, and modern colour functions.
Content tagged theming
Tutorial:CSS
@scope: Component-Level Style IsolationLimit where selectors match, with donut scopes and proximity.Use CSS @scope to keep component styles inside a root, stop them at a donut-scope limit, and let scope proximity fix nested themes.Post:CSS Container Queries Deep Dive: Named Containers,
cqiUnits, and Style QueriesMake components respond to their container, not the viewport.Go beyond basic @container: inline-size vs size containment, named containers, cqi/cqb/cqmin/cqmax units, and style queries, with diagrams and a live sandbox.Tutorial:One-Line Theme-Aware Colors with
light-dark()A single declaration per color, resolved automatically for both light and dark mode.The light-dark() CSS function collapses a light value and a dark value into one declaration, resolved by color-scheme — no duplicate custom properties, no @media (prefers-color-scheme) block per themed property.Tutorial:Theming Native Controls with
accent-colorTheme native checkboxes, radios and sliders with one property.The accent-color property themes the checked and filled parts of native checkboxes, radio buttons, switches, range sliders and progress bars — including their indeterminate states — while keeping real browser controls with full native behaviour and accessibility, plus how it pairs with color-scheme and what it leaves alone.