Master the advanced CSS custom property vocabulary — @property at-rule registration, the syntax and initial-value descriptors, inherits behaviour, and the JavaScript CSS.registerProperty() API for animatable variables.
0 / 5 completed
1 / 5
What does @property allow you to do with a CSS custom property?
@property is a CSS at-rule (mirroring CSS.registerProperty()) that gives a custom property a declared syntax, initial-value, and inherits flag. Registered properties can be transitioned and animated because the browser knows their type — unregistered properties are opaque strings that cannot be interpolated.
2 / 5
What does the syntax descriptor in @property specify?
The syntax descriptor defines the property's type using CSS value definition syntax. For example syntax: "<color>" tells the browser to parse the value as a color, enabling animated transitions between color values. syntax: "*" opts back into the untyped, non-interpolatable behaviour.
3 / 5
What is the purpose of initial-value in @property?
initial-value is mandatory when inherits: false and required for non-universal syntax values. It defines what the custom property resolves to when no value has been cascaded. Without it, the browser cannot guarantee a valid value for type-checked interpolation, which is why it's required for animatable registered properties.
4 / 5
What does inherits: false in an @property declaration mean?
Setting inherits: false makes the registered custom property non-inheriting. Each element resolves independently from initial-value unless the property is explicitly set on that element. This is useful for properties like animation progress counters where you do not want child elements to pick up a parent's value.
5 / 5
What is the JavaScript equivalent of @property for registering a custom property at runtime?
CSS.registerProperty() is the JavaScript API equivalent of the @property at-rule, available in the CSS Houdini Properties and Values API. It accepts the same options — name, syntax, inherits, initialValue — and must be called before any stylesheet uses the property to have effect.