How to create a theme switcher with HTML & CSS

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

Sign in to save videos and track what you’ve finished.

IntermediateUIWeb Design28 min

About this video

A walkthrough of building a color theme switcher with HTML and CSS, using custom properties and the :has() selector, with localStorage to remember the user's choice. It also covers a JavaScript fallback for browsers without :has() support.

What you’ll learn

  • Build a color theme picker using custom properties and the :has() selector
  • Save a user's theme choice with localStorage
  • Add a JavaScript fallback for browsers without :has() support