Transform lifts.translateY(-6px) moves the box up smoothly.
Prefer transform. It usually animates more smoothly than top/margin.
Edge Cases & Pitfalls
Most “broken” transitions come from where you put the property or what you try to animate.
base-rule
Put transition on the base state
If you only set transition inside :hover, the leave animation often snaps back. Keep it on the resting rule.
duration
Zero duration means no motion
Duration defaults to 0s. Without a positive time, you will not see a transition.
discrete
Not every property interpolates
Values like display are discrete. allow-discrete / transition-behavior can help in modern browsers, but prefer opacity/transform for beginners.
all
Use all carefully
transition: all … is handy for demos, but listing only the properties you need is clearer and often cheaper.
a11y
Respect reduced motion
In real UIs, shorten or disable motion under prefers-reduced-motion: reduce.
Compatibility
Browser Support
transition is a browser CSS property for UI state changes. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
transition
Chrome 26+, Firefox 16+, Safari 9+, Edge 12+, IE 10+. Widely available since September 2015. Newer longhands like transition-behavior vary.
98%Browser support
Google Chrome26+
Full support
Mozilla Firefox16+
Full support
Apple Safari9+
Full support
Microsoft Edge12+
Full support
Opera12.1+
Full support
Samsung Internet1.5+
Full support
Internet Explorer10+
Full support
transitionWidely supported
Bottom line: Safe for modern UI polish. Prefer opacity and transform. It is not a runtime API.
Remember
Key Takeaways
Shorthand: property, duration, easing, delay in one declaration.
Needs a change: transition only runs when a value actually changes.
Base rule: declare transition on the resting state so both directions animate.
vs animation: transition reacts to state; keyframes can loop on a timeline.
One line: use transition on the base rule to smooth property changes between states.
Frequently Asked Questions
It is a shorthand that animates changes between two CSS values over time — for example a background color or transform on hover.
The longhands default to all, 0s, ease, 0s, and normal. With duration 0s, you see no visible transition until you set a duration.
A transition runs when a property value changes (hover, class toggle). An animation uses keyframes and can loop without a state change.
Animatable values such as color, opacity, and transform work well. Discrete properties like display need special handling (allow-discrete) and are not beginner-friendly.
No. Set it on each element you want to animate.
It is Baseline and widely available since about September 2015. It is a browser CSS property, not a Node.js feature. Newer pieces like transition-behavior have narrower support.