Ask Lemmy @lemmy.world LemmyQuest @lemm.ee 1y ago Locked (Asking as someone who wants to create website) How to make website support dark mode without javascript?
(Asking as someone who wants to create website) How to make website support dark mode without javascript?
If you're not wanting to use JS then you're reliant on the users browser supporting prefers-color-scheme (caniuse) or forcing them to reload the page.
You can style both dark mode and light mode with CSS but the question is how will you toggle between them? A button? Then you need JavaScript
The user can toggle their operating system's setting. During development, the developer can do it in their browser's dev tools.
CSS prefers-color-scheme