1. CSS Custom Properties (Variables)
CSS variables allow you to store design tokens (colors, font sizes, spacing) centrally in the :root pseudo-class and update entire themes with a single declaration.
⊞HTML5 Web Code (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Variables & Theme Switcher</title>
<style>
:root {
--bg-color: #17181c;
--card-bg: #1f2029;
--text-color: #ffffff;
--accent-color: #04AA6D;
--border-color: #333333;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
font-family: Arial, sans-serif;
padding: 30px;
}
.theme-card {
background-color: var(--card-bg);
border: 1px solid var(--border-color);
padding: 24px;
border-radius: 12px;
max-width: 400px;
margin: 0 auto;
text-align: center;
}
.accent-btn {
background-color: var(--accent-color);
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 6px;
font-weight: bold;
cursor: pointer;
margin-top: 12px;
}
</style>
</head>
<body>
<div class="theme-card">
<h2>Tokenized Design System</h2>
<p>Using CSS variables enables instant dark/light theme switching.</p>
<button class="accent-btn">Dynamic Button</button>
</div>
</body>
</html>
