Inverted themes with light-dark()

“Inverted themes with light-dark()” title and six themed cards: theme=light, theme=dark, theme=inverted, and nested .card.funky variations with inverted themes.

Dave Rupert explains how to build adaptive theme switching using the CSS light-dark() function and container style queries. The technique uses a data-theme="inverted" attribute to automatically flip elements to their opposite color scheme based on browser preference, all in a single stylesheet without duplication. For browsers lacking container style query support, a JavaScript polyfill provides graceful degradation.

daverupert.com/2026/04/inverted-light-dark