0Pricing
CSS Academy · Lesson

CSS Properties and Values API (@property)

Register custom properties with types and inheritance using @property for animatable CSS variables.

CSS Properties and Values API (@property) is a free CSS Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What is @property?

@property is the CSS way to register a custom property with a type, inheritance behavior, and initial value. It is the declarative form of the CSS Properties and Values API (CSS.registerProperty).

@property Syntax

Register a custom property with three required descriptors:

@property --rotation {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

syntax Descriptor

The syntax descriptor defines the property's type using CSS type names:

  • "<number>", "<integer>", "<percentage>"
  • "<angle>", "<color>", "<length>"
  • "<image>", "<transform-list>"
  • "*" — accept any value (like unregistered)

inherits Descriptor

Controls whether the property inherits through the DOM. Set false for properties that should be isolated per element.

initial-value Descriptor

Provides a guaranteed initial value when the property is not set. This makes the property animatable.

Animating Custom Properties

The key benefit of @property: registered custom properties can be transitioned and animated because the browser knows their type and can interpolate between values:

@property --hue {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.element {
  background: hsl(var(--hue), 70%, 50%);
  transition: --hue 1000ms ease;
}

.element:hover {
  --hue: 180;
  /* hue animates from 0 to 180 smoothly */
}

Without @property

Without registration, CSS does not know custom property types. Transitions between two variable values snap rather than interpolate — the browser cannot calculate the midpoint of an unknown type.

@property for Gradient Animation

Animating gradient stops (previously impossible without @property):

@property --gradient-stop {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.loader {
  background: conic-gradient(royalblue var(--gradient-stop), transparent 0);
  transition: --gradient-stop 1s ease;
}

.loader.loading {
  --gradient-stop: 75%;
}

JavaScript Equivalent

You can also register properties using the JavaScript API:

CSS.registerProperty({
  name: '--rotation',
  syntax: '<angle>',
  inherits: false,
  initialValue: '0deg'
});

Browser Support

@property is supported in Chrome 85+, Edge 85+, Safari 16.4+, Firefox 128+. Widely available in modern browsers.

Practical @property Uses

Common use cases:

  • Animating gradient positions and colors
  • Animating hue/saturation in HSL colors
  • Progress bar fill animations
  • Counter animations for number reveals
  • Smooth dark/light mode transitions via color token animations

Quick Check

Why is @property required for animating CSS custom properties?

Recap

@property registers custom properties with a syntax type, inherits flag, and initial-value. Registered properties are animatable and transitionable because the browser can interpolate their typed values. This enables gradient animations, hue transitions, and counter animations that are impossible with unregistered custom properties.

Frequently asked questions

Is the “CSS Properties and Values API (@property)” lesson free?

Yes — the full text of “CSS Properties and Values API (@property)” is free to read here on the web, and the CSS Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO.

What will I learn in “CSS Properties and Values API (@property)”?

Register custom properties with types and inheritance using @property for animatable CSS variables. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “CSS Properties and Values API (@property)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The CSS Typed Object Model (OM)
  2. CSS Properties and Values API (@property)
  3. CSS Paint API: Worklets
  4. CSS Layout API and Scope
← Back to CSS Academy