Skip to main content

Harshal V. LADHE

Building Dark Mode on the Web

Approaches for adding dark mode to websites, from system-preference detection to theme-aware CSS colours.

Content tagged dark-mode

  • 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:3 min read