at-rule

@property — CSS reference

Register a custom property with grammar, inheritance behavior and initial value. Syntax and inherits are required; non-universal syntax requires a computationally independent initial value. Invalid registrations are ignored. Registration permits type-aware validation and interpolation.

Formal Syntax & Structure

css syntaxcss
@property --gap { syntax: "<length>"; inherits: false; initial-value: 12px; }

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}@property --gap{syntax:"<length>";inherits:false;initial-value:12px} #parent{--gap:80px} .sample{width:var(--gap)} #b{--gap:30px}</style><body><div id="parent"><div id="a" class="sample">A</div><div id="b" class="sample">B</div></div></body></html>
CSS Reference