Skip to content

marcus-hugo/dark-light-css-only

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CSS Only Dark/Light Theme

A simple webpage tutorial for a CSS only dark/light theme solution.

Without adding a reset or styles, this is the css that makes it work color-scheme and prefers-color-scheme, and together:

@media (prefers-color-scheme: light) {
  html {
    color-scheme: light;
  }
}

@media (prefers-color-scheme: dark) {
  html {
    color-scheme: dark;
  }
}

The colors for the code blocks were inspired by Tania Rascia's New Moon theme. here's a link [https://github.com/taniarascia/new-moon]

Will build on this project for the next tutorial with a toggle switch and JavaScript to come soon...

Releases

No releases published

Packages

No packages published