Property
Only animate the CSS properties that actually need motion.
Transitions make state changes feel intentional. They smooth the jump between one CSS value and another without turning the interface into a show.
.button { transition: transform 180ms ease, background-color 180ms ease; }
.button:hover { transform: translateY(-2px); }
Motion mental model
A transition tells the browser to animate the change between two values. A button background can fade, a card can lift, a border can brighten and a menu underline can grow.
The important word is change. A transition does not start by itself. It reacts when a property changes through hover, focus, an added class, a media query or JavaScript.
Good transitions are short, specific and useful. They make the interface feel responsive. Slow or vague transitions make the page feel heavy.
Only animate the CSS properties that actually need motion.
Most interface transitions live between 120ms and 260ms.
Easing controls the acceleration and emotional feel of the change.
The change can come from hover, focus, active, class changes or state attributes.
Visual model
The component waits in its default visual state.
Hover, focus or a class updates a value.
The browser draws the values between start and end.
The component lands in its changed state.
Good CSS versus fragile CSS
.button {
transition: transform 160ms ease,
background-color 160ms ease,
border-color 160ms ease;
}
.button:hover { transform: translateY(-2px); }
.button {
transition: all 2s ease;
}
.button:hover { width: 300px; margin-left: 80px; }
Rules of thumb
Write the properties by name so future CSS changes do not accidentally animate.
Hover and focus feedback should feel instant, usually below 250ms.
Transform and opacity are usually smoother than width, height, top or left.
A tiny hover lift needs a tiny duration; a panel reveal can be slightly longer.
It hides intent and can animate expensive or unexpected properties later.
A transition that feels nice once can feel annoying after the twentieth click.
Production thinking
Transitions help users perceive cause and effect. They show that the interface responded to their action instead of snapping randomly.
Short transitions are usually fine, but users with vestibular sensitivity may still prefer reduced motion. Pair larger movement with a reduced-motion fallback.
Define motion tokens such as --motion-fast and --ease-standard once the design system grows.
Transitions do not rank pages by themselves, but good interaction polish improves perceived quality and engagement.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the motion has no purpose, no fallback or no state clarity, it is not production motion yet.
Senior audit upgrade
Timing and easing should not be random. A few reusable motion tokens keep interaction polish controlled.
--motion-fast for tiny feedback such as hover color.
--motion-standard for panel, menu and card state changes.
Use easing to make motion feel responsive instead of robotic.
:root {
--motion-fast: 120ms;
--motion-standard: 220ms;
--ease-out: cubic-bezier(.2, .8, .2, 1);
}