Implementing Dark Theme for the Web

A summary of various approaches to style a webpage to match the user’s system theme using CSS, HTML and native javascript.

Approach 1: Just CSS — `prefers-color-scheme’

The classic method: detect user’s theme preference with CSS media feature .