Skip to main content

Harshal V. LADHE

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 Isolation

    Limit 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.
    Published at:
    Categories:CSS
    Estimated reading time:8 min read
  • Post:CSS Container Queries Deep Dive: Named Containers, cqi Units, and Style Queries

    Make 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.
    Published at:
    Categories:CSS
    Estimated reading time:25 min read
  • 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.
    Published at:
    Categories:CSS
    Estimated reading time:5 min read
  • Tutorial:Theming Native Controls with accent-color

    Theme 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.
    Published at:
    Categories:CSS
    Estimated reading time:8 min read