Registered custom properties
Definition and purpose
Registration adds a value grammar, initial value and inheritance policy to a custom property. This is useful for typed design tokens and animations because the engine knows whether a value is a length, number or color.
Non-inheriting token
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } @property --gap { syntax: "<length>"; inherits: false; initial-value: 8px; } #parent { --gap: 20px; padding: var(--gap); } #a { padding: var(--gap); } </style> </head> <body> <div id="parent"> <div id="a">Child</div> <div id="b">Other</div> </div> </body></html>The child uses the registered initial value, not the parent token.
Syntax and mental model
Use @property --gap { syntax: "<length>"; inherits: false; initial-value: 8px; }. Syntax and inherits are required; initial-value is required except with universal syntax *. For typed syntax the initial value must be computationally independent (8px works, 2em does not). A non-inheriting registration defaults on children unless explicitly inherited.
Invalid typed input
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } @property --gap { syntax: "<length>"; inherits: false; initial-value: 8px; } #a { --gap: red; padding: var(--gap); } </style> </head> <body> <div id="parent"> <div id="a">Child</div> <div id="b">Other</div> </div> </body></html>Red is not a length, so the registration provides 8px.
Common mistakes
Registration is not a component-local declaration; choose distinct names to avoid collisions. A browser without registration support may still accept ordinary custom properties, so test fallback behavior separately.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Inheritance and invalid value behavior. Next lesson: Semantic tokens and themes.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Registered custom properties — knowledge check
Five questions on registered custom properties.
Which descriptor defines accepted value types?
Which descriptor prevents default inheritance?
Which initial length is computationally independent?
When may initial-value be omitted?
What enables typed interpolation of a numeric token?