section {
--main-bg-color: brown;
}Using CSS custom properties (variables) / notebook
Using CSS custom properties (variables)
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
:root {
--main-bg-color: brown;
}@property --logo-color {
syntax: "<color>";
inherits: false;
initial-value: #c0ffee;
}details {
background-color: var(--main-bg-color);
}<div class="container">
<div class="one">
<p>One</p>
</div>
<div class="two">
<p>Two</p>
<div class="three">
<p>Three</p>
</div>
</div>
<input class="four" placeholder="Four" />
<textarea class="five">Five</textarea>
</div>