// Update button text & save preference if (body.classList.contains('dark')) button.textContent = '☀️ Light Mode'; localStorage.setItem('theme', 'dark'); else button.textContent = '🌙 Dark Mode'; localStorage.setItem('theme', 'light');
h1 font-size: 2rem; margin-bottom: 0.5rem; html css javascript crash course
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Theme Switcher | Crash Course</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <h1>🎨 HTML + CSS + JS Crash Course</h1> <p>Click the button to switch between light and dark themes.</p> <button id="themeBtn">🌙 Dark Mode</button> <div class="demo-box"> <p>This box changes style with the theme!</p> </div> </div> <script src="script.js"></script> </body> </html> CSS handles colors, fonts, spacing, and responsiveness. // Update button text & save preference if (body