:root {
--base: #000;
}
div {
background-color: var(--base)
}
You can also set variables in-line: <html style='--base: #fff'>. If you put the variables in the :rootyou can change them like so: document.documentElement.style.setProperty('--base', ‘20px') and change them throughout the DOM.
Variables in CSS
You can also set variables in-line:
<html style='--base: #fff'>
. If you put the variables in the:root
you can change them like so:document.documentElement.style.setProperty('--base', ‘20px')
and change them throughout the DOM.