Agyan
adda
Run
Reset
Copy
CSS Tutorial › CSS Variables › Theme with variables
Back to tutorial
Code
Edit, then press Run or Ctrl+Enter
<style> :root { --bg: #ffffff; --text: #222; --primary: #1f386b; } .dark { --bg: #1e1e1e; --text: #eee; --primary: #4a90e2; } .panel { background: var(--bg); color: var(--text); padding: 16px; border: 2px solid var(--primary); border-radius: 8px; margin-bottom: 10px; } .panel h3 { color: var(--primary); margin-top: 0; } </style> <div class="panel"><h3>Light theme</h3>Same CSS rules.</div> <div class="panel dark"><h3>Dark theme</h3>Only the variables changed.</div>
Result