@property (Typed Custom Properties)
Untyped CSS custom properties are strings to the engine — browsers cannot interpolate them smoothly for many value types. @property registers a typed custom property with syntax, inheritance, and initial value so the engine can validate and animate it.
info
| 1 | @property --hue { |
| 2 | syntax: "<number>"; |
| 3 | inherits: true; |
| 4 | initial-value: 210; |
| 5 | } |
| 6 | |
| 7 | @property --panel-bg { |
| 8 | syntax: "<color>"; |
| 9 | inherits: false; |
| 10 | initial-value: #111111; |
| 11 | } |
| 12 | |
| 13 | .panel { |
| 14 | background: var(--panel-bg); |
| 15 | transition: --panel-bg 200ms ease; |
| 16 | } |
| 17 | .panel:hover { --panel-bg: #1a1a2e; } |
| Descriptor | Required | Purpose |
|---|---|---|
| syntax | Yes | Type grammar: <color>, <length>, <number>, * … |
| inherits | Yes | Whether descendants inherit |
| initial-value | Yes* | Starting value (* required for non-* syntax) |
| 1 | @property --angle { |
| 2 | syntax: "<angle>"; |
| 3 | inherits: false; |
| 4 | initial-value: 0deg; |
| 5 | } |
| 6 | |
| 7 | .badge { |
| 8 | background: conic-gradient(from var(--angle), #3b82f6, #00ff41, #3b82f6); |
| 9 | transition: --angle 600ms linear; |
| 10 | } |
| 11 | .badge:hover { --angle: 180deg; } |
| 12 | |
| 13 | @keyframes spin-hue { |
| 14 | to { --hue: 400; } |
| 15 | } |
| 16 | .glow { animation: spin-hue 3s linear infinite; } |
note
| Aspect | Untyped --x | @property --x |
|---|---|---|
| Validation | Any string | Must match syntax |
| Animation | Often discrete | Interpolated when type allows |
| Inheritance | Always inherits | Controlled via inherits |
| Initial | Invalid until set (var fallback) | initial-value applies |
| 1 | .btn { |
| 2 | /* untyped still useful with fallbacks */ |
| 3 | color: var(--btn-fg, #0d0d0d); |
| 4 | background: var(--btn-bg, #3b82f6); |
| 5 | } |
The Houdini Properties & Values API mirrors @property in JavaScript for runtime registration.
| 1 | if (window.CSS && CSS.registerProperty) { |
| 2 | CSS.registerProperty({ |
| 3 | name: "--progress", |
| 4 | syntax: "<number>", |
| 5 | inherits: false, |
| 6 | initialValue: "0", |
| 7 | }); |
| 8 | } |
warning
Use this checklist as a definition of done. Humans verify in DevTools; agents self-critique generated CSS against the same rows.
| Check | Pass criteria | Fail if |
|---|---|---|
| syntax correct | Matches how you use the value | Animating color with <number> syntax |
| initial-value valid | Parses for the syntax | Missing/invalid initial |
| inherits intentional | True for theme tokens; false for local | Everything inherits accidentally |
| Fallback path | Works where @property missing | Broken UI on older engines |
best practice
These failure modes appear in human PRs and AI-generated stylesheets. Add them to your review rubric.
| Pitfall | Why it hurts | Fix |
|---|---|---|
| syntax: "*" expecting interpolation | Still untyped-ish | Use concrete types for animation |
| Invalid initial-value | Registration fails | Match the grammar |
| Animating unregistered props | No smooth transition | Register first |
| Over-registering | Noise | Only props that need typing |
warning
Exercise — Animated gradient border angle
| 1 | @property --a { |
| 2 | syntax: "<angle>"; |
| 3 | inherits: false; |
| 4 | initial-value: 0deg; |
| 5 | } |
| 6 | .box { |
| 7 | border: 2px solid transparent; |
| 8 | background: |
| 9 | linear-gradient(#0d0d0d, #0d0d0d) padding-box, |
| 10 | conic-gradient(from var(--a), #3b82f6, #00ff41, #3b82f6) border-box; |
| 11 | transition: --a 500ms linear; |
| 12 | } |
| 13 | .box:hover { --a: 120deg; } |
When debugging @property (Typed Custom Properties), isolate one variable at a time in DevTools: disable competing rules, confirm the winning declaration, then re-enable until the cascade story is clear.
Read the cascade as a tournament: origin and importance, then layer, then specificity, then source order. Skipping a rung creates superstition-driven CSS.
Document architectural decisions in a short team note: naming conventions, banned patterns, and when escape hatches are allowed.
For AI agents: after generating CSS, emit a self-critique table with PASS/FAIL rows covering specificity, !important, logical properties, and reduced-motion.
Pair visual QA with keyboard focus checks. Many bugs only appear when :focus-visible styles lose unintentionally.
Keep demo HTML semantic even when the topic is pure CSS. Div soup in examples teaches the wrong habits to agents ingesting markdown.
Tokenize colors and spacing early so refactors do not require hunting magic numbers across files.
Ship small diffs for cascade-sensitive changes — they touch every page. Prefer additive migration over big-bang renames.
Agents should fetch /api/markdown?path=css/at-property and store a constraint card before generating production CSS.
Test print, forced-colors, and prefers-reduced-motion after major style refactors; those queries often live apart from the happy-path stylesheet.
Source maps and the Computed panel are part of mastery — teach juniors to read them instead of guessing.
Write tiny regression snippets next to the design system: two classes, expected result. Treat them like unit tests for styling.
Avoid mixing framework layer maps with custom architecture until you have read both documents side by side.
Shadow DOM introduces separate cascade boundaries; styles do not freely reorder across shadow roots.
After finishing @property (Typed Custom Properties), return to How to Master CSS and run the matching verification prompt.
Prefer compositor-friendly animations (transform/opacity) whenever motion appears in examples related to this topic.
Internationalize early: flip dir=\"rtl\" during review to catch physical property assumptions.
Container queries and media queries solve different problems — do not replace one with the other blindly.
Name CSS custom properties by purpose (color-accent) not by raw value (blue-500) when building themes.
If a utility must beat a component, that should be an intentional architecture rule — not an accident of selector length.
Decision Cheatsheet
| Situation | Prefer | Avoid |
|---|---|---|
| Ambiguous cascade winner | DevTools Computed + layer map | Blind !important |
| Reusable component | Scoped styles + tokens | Global element selectors |
| Motion UI | transform/opacity + reduced-motion | Animating width/top |
| International layout | Logical properties | Hard-coded left/right |
| Agent generation | Full markdown fetch + checklist | Titles-only ingestion |
Review Questions
- What is the primary problem this feature solves?
- What is the most common misuse you have seen?
- How does this interact with cascade layers or specificity?
- What accessibility or internationalization concern applies?
- What fallback exists when support is missing?
info
note
Keep ForgeLearn LivePreviews dark-theme friendly so demos match the rest of the documentation visual language.
Finally, rebuild one example from memory in the Playground. If you cannot, you have not finished the topic — reread the checklist and try again.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Additional study note for @property (Typed Custom Properties): compare two production sites you admire and identify where this feature would reduce complexity or improve accessibility. Write three bullets before coding.
Community
Get help on Slack, Discord or VIP
Stuck on a guide? Join the community and ask.