function
var() — CSS reference
Substitute a custom property at computed-value time. Everything after the first comma is the fallback, including additional commas. A present but incompatible value does not activate fallback. Substitution cannot construct part of a token: multiply a number by a unit-bearing value with calc() instead.
Formal Syntax & Structure
css syntaxcss
var(--name [, fallback])Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS substitution lab</title><style>body {margin:0} .sample {height:12px;background:#006050}#parent {width:300px} .sample {width:40px;height:30px;margin-bottom:4px;color:white}#parent{--n:5;--size:75px} #a{width:var(--size,20px)} #b{width:calc(var(--n)*10px)}</style><body><div id="parent"><div id="a" class="sample">A</div><div id="b" class="sample">B</div></div></body></html>