Creating Dark theme and Light theme in HTML + CSS is a very common feature in modern websites. It allows users to switch between light mode and dark mode.
Basic Light and Dark Theme using CSS Variables
HTML
CSS
JavaScript
Output - Light Theme
Output - Dark Theme
How it works
- CSS Variables define colors.
- Default theme - Light mode.
- When button clicked - dark theme class added.
- Variables change automatically.





Top comments (0)