Dark mode with a media query!

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

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

IntermediateUI5 min

About this video

A CSS tutorial on adding dark mode to a website that switches automatically based on the user's system preference, using a media query and custom properties for colours.

What you’ll learn

  • Set up colour custom properties for a site's theme
  • Switch colours automatically with a prefers-color-scheme media query