The transition-duration property controls how long a CSS transition takes — from instant snaps to slow, gradual changes. It is essential for polished hover and state-change effects.
01
Speed
Control animation length.
02
Time units
Seconds and ms.
03
Shorthand
Second value in transition.
04
Fast UI
0.1–0.3s for buttons.
05
Slow FX
1s+ for emphasis.
06
vs delay
Duration ≠ wait time.
Fundamentals
Introduction
The transition-duration property in CSS is used to define the length of time that a transition animation takes to complete. It is part of the CSS Transitions module and allows you to control how long an element should take to change from one style to another.
This property can be particularly useful for creating smooth, visually appealing transitions for various user interactions.
Definition and Usage
Set transition-duration alongside transition-property (or use the transition shorthand). Without a positive duration, changes happen instantly because the default is 0s.
💡
Beginner Tip
For buttons and links, try 0.15s to 0.3s. For large panels or background fades, 0.4s to 0.8s often feels natural.
Foundation
📝 Syntax
The syntax for the transition-duration property is simple. You specify the duration of the transition in seconds (s) or milliseconds (ms).
syntax.css
element{transition-duration:time;}
Here, time represents the duration of the transition.
Open Try It Yourself to hover and click the button with 0.15s transitions.
How It Works
UI controls benefit from fast durations. Overriding to 0.05s on :active makes the press feel immediate.
A11y
♿ Accessibility
Reduced motion — Set transition-duration: 0.01ms or disable transitions when prefers-reduced-motion: reduce is set.
Do not slow essential feedback — Form errors and loading states should not use long durations.
Focus parity — Apply the same durations on :focus-visible as on hover.
Avoid motion sickness — Very long transitions on large areas can disorient some users.
Companion
duration vs delay
transition-duration controls how long the animation runs. transition-delay controls how long to wait before it starts. Both use time units but serve different roles.
duration-delay.css
.box{transition-property:opacity;transition-duration:0.5s;/* runs for half a second */transition-delay:0.3s;/* waits 0.3s before starting */}
🧠 How transition-duration Works
1
Duration is set
Define how long the transition should run, e.g. 0.3s.
Setup
2
Property value changes
Hover, focus, or a class toggle triggers a new CSS value.
Trigger
3
Browser animates over time
The property interpolates from old to new value for the full duration.
Animate
=
✅
Smooth change at chosen speed
Users see a gradual shift instead of an instant jump.
Compatibility
Browser Compatibility
The transition-duration property is well-supported in modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It is advisable to test your website across different browsers to ensure compatibility.
✓ Modern browsers · Widely supported
Transition timing everywhere
transition-duration works in current Chrome, Firefox, Safari, Edge, and Opera alongside other transition properties.
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 duration feel on real devices — what feels fast on desktop may feel too slow on mobile touch interactions.
transition-duration property98% supported
Bottom line:transition-duration is safe to use for controlling transition speed in modern browsers.
Wrap Up
Conclusion
The transition-duration property is an essential tool for web developers looking to create smooth, gradual transitions between different states of an element.
By specifying the duration of these transitions, you can enhance the user experience and add a touch of elegance to your web projects. Experiment with different durations to see how this property can improve the visual dynamics of your website.
Use 0.15–0.3s for buttons, links, and small UI elements
Always set a positive duration when you want visible motion
Pair with transition-property or use the shorthand
Test fast vs slow to find the right feel for each component
Respect prefers-reduced-motion: reduce
❌ Don’t
Leave duration at default 0s and wonder why nothing animates
Use multi-second durations on primary interactive controls
Confuse duration with delay — they control different timing
Use negative time values (they are invalid)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about transition-duration
Use these points when choosing transition speed.
5
Core concepts
⏱01
Length
How long it runs.
Purpose
🕐02
Default 0s
Instant change.
Default
📈03
s and ms
Time units.
Values
⚡04
UI speed
0.15–0.3s.
Pattern
📚05
Not delay
Different role.
Compare
❓ Frequently Asked Questions
transition-duration sets how long a CSS transition takes to complete after it starts, controlling the speed of the animation between two property values.
The default is 0s, which means no visible transition unless you specify a positive duration.
Yes. Use seconds like 2s or milliseconds like 200ms. Negative values are not allowed.
transition-duration controls how long the animation runs. transition-delay controls how long to wait before the animation starts.
No, transition-duration is not inherited. Set it on each element that needs a timed transition.