When a property's value changes (for example, a :hover state triggered by the mouse), the browser jumps to the new value instantly by default. transition smooths that change over time — it is the cheapest animation tool to learn and gives the most immediate payoff.
The Four Sub-properties
Property
Purpose
Default
transition-property
Specifies which properties participate in the transition
all
transition-duration
Transition duration
0s (no transition)
transition-timing-function
Easing curve
ease
transition-delay
Delay before the transition starts
0s
.btn {
transition-property: background, transform;
transition-duration: .2s;
transition-timing-function: ease-out;
}
/* The shorthand form, more commonly used */.btn { transition: background .2s ease-out, transform .2s ease-out; }
Easing Functions
Easing functions describe how speed changes over time; choosing the right curve makes the motion feel natural instead of mechanically uniform.
Keyword
Speed profile
Best for
linear
Constant speed
Mechanical scenarios like loading progress bars
ease
Accelerate then decelerate (default)
Most general-purpose scenarios
ease-out
Fast in, slow out
Elements entering the viewport, expanding
ease-in
Slow in, fast out
Elements leaving the viewport, collapsing
cubic-bezier(x1,y1,x2,y2)
Custom curve
Brand motion that needs fine tuning
Hover to compare different easing (feel the accelerate/decelerate of the movement)
linear
ease-out
spring curve
Which Properties Can Transition
Not every CSS property can transition — only properties whose values can be interpolated, such as colors, lengths, opacity, and the parameters of transform functions. Discrete keyword properties like display cannot transition smoothly (it is either block or none, with no intermediate state).
Common need: transitioning display togglesNewer browsers support putting display and content-visibility into transition-property, combined with @starting-style, to achieve a "fade in from none" effect; before that, the common practice is to simulate it with a visibility + opacity combination.
Per-Property Transitions
Separating properties with commas lets you set different durations and delays for each, giving composite motion more depth:
.dropdown {
transition:
opacity .15s ease,
transform .2s ease-out .05s; /* the transform starts 50ms later than the opacity */
}
Respecting the Reduced-Motion Preference
Recall prefers-reduced-motion from Section 3.2 — any project that introduces transition/transform should also provide a reduced version: