Skip to content

Chapter 1 of 7

Foundations: Why Animate with CSS?

CSS gives designers two complementary tools for motion on the web: transitions and animations. A transition is designed to animate smoothly between two states of a property when that property changes, interpolating intermediate values over time. An animation, by contrast, animates an element through multiple keyframes over time, supports loops and complex multi-step sequences, and runs automatically without requiring any state change to trigger it. In short, transitions react to changes, while animations drive a timeline on their own.

This distinction shapes when you reach for each tool. A transition needs an event — typically a pseudo-class like :hover or :focus, a class change, or a JavaScript style update — to begin, and it runs once between the old and new values. An animation can be defined declaratively with @keyframes and will play on its own schedule, optionally looping forever. The two can be combined: an animation may itself be paused or replayed by toggling a class, but the animation is not strictly dependent on that toggle to function.

It is also important not to confuse transition with transform. The transform property changes an element's geometry using functions like translate, rotate, and scale; transition is the mechanism that animates any animatable property when its value changes. Transforms are commonly the things being transitioned or animated, but transition itself does not move things — it animates changes.

All chapters
  1. 1Foundations: Why Animate with CSS?
  2. 2Transitions: Animating Property Changes
  3. 3@keyframes Animations: Multi-Step Sequences
  4. 4Easing: Controlling the Feel of Motion
  5. 5Transforms: Moving and Shaping Elements
  6. 6Performance: The Rendering Pipeline
  7. 7Practical Effects, Accessibility, and Modern Features

Drill it

Reading is not remembering. These come from the CSS Animations And Transitions deck:

Q

What is the main purpose of CSS transitions?

To animate smoothly between two states of a property when it changes, interpolating intermediate values over time.

Q

What is the main purpose of CSS animations?

To animate an element through multiple keyframes over time, including loops and complex multi-step sequences, without needing state changes.

Q

Which CSS property enables a transition?

transition: ; shorthand for transition-property, transition-duration, transition-timing-function, and transition-delay.

Q

What is transition-property?

A longhand that names the CSS property (or "all") whose changes should be animated. Defaults to "all".