Modern websites almost always support dark mode now.

CSS provides built-in detection using:

@media (prefers-color-scheme: dark)

What It Does

Detects user's system theme.

If system is dark mode →

CSS inside media query activates.


body{
 background:white;
 color:black;
}

@media(prefers-color-scheme:dark){

 body{
  background:black;
  color:white;
 }

}


Dark Mode Change your system theme between light and dark HTML Sandbox — click to edit