The transition property lets you animate CSS changes smoothly over time — perfect for hover effects, focus states, and polished UI feedback without JavaScript.
01
Shorthand
One line, four parts.
02
Duration
Control speed in seconds.
03
Timing
ease, linear, and more.
04
Delay
Wait before starting.
05
Hover UI
Buttons and cards.
06
Motion safety
Respect user prefs.
Fundamentals
Introduction
The transition property in CSS allows you to change property values smoothly over a given duration. It is commonly used to create animations and enhance user interactions by animating the changes of CSS properties. This makes your web pages more dynamic and engaging.
Definition and Usage
Use transition on the base state of an element (not only on :hover) so the browser knows how to animate both directions — when the state changes in and when it changes back.
💡
Beginner Tip
Always include a duration (for example 0.3s). Without it, the default is 0s and you will not see any animation.
Foundation
📝 Syntax
The transition property is a shorthand for four individual transition properties:
transition-property — which CSS property to animate
transition-duration — how long the animation takes
transition-timing-function — the speed curve
transition-delay — wait time before the transition starts
The base button sets transition: background-color 0.5s ease. When hover changes the color, the browser animates between blue and red over half a second.
Example 2 — Multiple properties at once
Transition width, height, and box-shadow together for a richer hover effect.
Set property, duration, timing, and delay on the element’s default rule.
Setup
2
Property value changes
Hover, focus, or a class toggle updates a CSS property to a new value.
Trigger
3
Browser interpolates
The browser animates from the old value to the new value over the duration.
Animate
=
✅
Smooth visual change
Users see polished motion instead of an instant jump.
Compatibility
Browser Compatibility
The transition property is well-supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is always a good practice to test your website across different browsers to ensure compatibility.
✓ Modern browsers · Widely supported
CSS transitions everywhere
transition works in current Chrome, Firefox, Safari, Edge, and Opera for hover and state-change animations.
98%Browser support
Google Chrome26+ · Desktop & Mobile
Full support
Mozilla Firefox16+ · Desktop & Mobile
Full support
Apple Safari6.1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera12.1+ · All versions
Full support
Testing tip
Test hover transitions on touch devices; some browsers do not fire hover until tap, so provide equivalent focus or active states.
transition property98% supported
Bottom line:transition is safe to use for modern interactive UI polish.
Wrap Up
Conclusion
The transition property is a versatile and powerful tool for web developers, enabling the creation of smooth animations and enhancing the user experience.
By specifying transitions for different properties, durations, timing functions, and delays, you can create visually appealing effects that make your web pages more engaging and interactive. Experiment with different combinations and see how the transition property can bring your web projects to life.
Rely on hover-only effects for critical information
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about transition
Use these points when adding motion to your UI.
5
Core concepts
📚01
Shorthand
Four parts in one.
Syntax
⏱02
Duration
Always set time.
Speed
📈03
Timing
ease vs linear.
Curve
👁04
Trigger
Hover or class.
Usage
♿05
Motion
Respect prefs.
A11y
❓ Frequently Asked Questions
transition smoothly animates changes between two CSS property values over a set duration, such as fading a background color or moving an element on hover.
The default is none 0s ease 0s, which means no transition effect is applied unless you specify one.
transition runs when a property value changes, like on hover. animation runs keyframes on a timeline and can loop without a trigger.
Most animatable properties work, including color, opacity, transform, width, and height. Layout-heavy properties like display are not transition-friendly.
No, transition is not inherited. Set it on each element you want to animate.