Home CSS Properties transition-duration CSS transition-duration Property Definition
Definition and Usage The transition-duration property sets how long a CSS transition takes to finish. The initial value is 0s, so changes are instant until you set a positive time.
Use a <time> in seconds (s) or milliseconds (ms). It is not inherited. Pair it with transition-property (what changes), transition-timing-function (easing), and transition-delay (wait time), or the transition shorthand.
Baseline · Widely available. Not deprecated. Standard-track CSS. Negative times are invalid. Prefer shorter durations for UI feedback, and respect prefers-reduced-motion when motion can distract.
Syntax
CSS Syntax transition-duration: <time> | <time>, <time>, … | initial | inherit ;
Examples: transition-duration: 0.3s; · transition-duration: 300ms; · transition-duration: 1s, 200ms;
Values
Property Values Value Description Try it <time> (s)Duration in seconds, such as 0.5s or 2s Try it<time> (ms)Duration in milliseconds, such as 200ms Try it0sDefault. Instant change (no visible transition) Try itMultiple times Comma-separated list mapped to transition-property Try itinitialResets to 0s Try itinheritTakes the value from the parent element Try it
Approach
How to Use transition-duration Pick what changes, then decide how long that change should take.
Choose a property that can transition (for example background-color or transform). Set transition-property (or use the transition shorthand). Set transition-duration to a positive time such as 0.25s or 250ms. Trigger a state change (hover, class toggle, focus) and watch the timed change. Piece Required? Role Transitionable property Yes Something must change between two states Positive duration Yes (to see motion) Default 0s is instant State change Yes Hover, focus, class, or media change starts it Timing / delay Optional Easing and wait time polish the feel
Try it
Live Preview Hover or focus the box. Only transition-duration changes — longer values take more time to finish.
Code
CSS Examples Each snippet focuses on transition-duration. Other transition pieces are only there so a change can run. Use Try It Yourself for a live editor.
1. Seconds 2. Milliseconds 3. Multiple Example 1 — Duration in Seconds Take half a second to change the background on hover.
<style>
button {
background: #2563eb;
color: #fff;
border: 0;
padding: 12px 16px;
transition-property: background-color;
transition-duration: 0.5s;
}
button:hover,
button:focus-visible {
background: #16a34a;
}
</style>
<button type="button">Hover me</button> How It Works Name what changes. transition-property: background-color limits the transition.Set the length. transition-duration: 0.5s is the lesson — half a second.Provide two states. Default blue, hover/focus green.Watch the blend. The color morphs over 0.5s instead of jumping.Example 2 — Duration in Milliseconds Use ms for a snappy UI feel.
<style>
button {
background: #2563eb;
color: #fff;
border: 0;
padding: 12px 16px;
transition-property: background-color;
transition-duration: 200ms;
}
button:hover,
button:focus-visible {
background: #16a34a;
}
</style>
<button type="button">Quick hover</button> How It Works Same pattern as seconds. Only the time unit changes.Use milliseconds. 200ms equals 0.2s.Keep UI short. Buttons often feel best around 150–300ms.Unit is required. Write 0ms or 0s, never bare 0.Example 3 — Multiple Durations Give each transitioning property its own length of time.
<style>
button {
background: #2563eb;
color: #fff;
border: 0;
padding: 12px 16px;
transition-property: background-color, transform;
transition-duration: 200ms, 1s;
}
button:hover,
button:focus-visible {
background: #16a34a;
transform: translateX(12px);
}
</style>
<button type="button">Color fast, move slow</button> How It Works List the properties. transition-property is the master list.List matching times. First duration pairs with the first property.Here: color then move. Background uses 200ms; transform uses 1s.Lists can cycle or truncate. If counts differ, the browser repeats or trims the duration list. Edge Cases & Pitfalls If nothing seems to animate, check these first.
0s Default duration is instant With 0s, the property still “transitions,” but you will not see motion. Set a positive time to observe it.
units Time needs a unit Use 0s or 0ms. Bare 0 is invalid for <time>. Negative values invalidate the declaration.
property Only some properties interpolate Duration alone is not enough. The changing property must be transitionable, and a real state change must occur.
lists Multiple durations follow transition-property Times map in order to the property list. Too few durations repeat; too many are truncated.
a11y Respect reduced motion Long or large motion can distract. Offer a shorter duration (or none) under @media (prefers-reduced-motion: reduce).
Compatibility
Browser Support transition-duration is a browser CSS property for transition timing. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
transition-duration Widely supported across modern browsers since about September 2015. Seconds, milliseconds, and comma-separated lists are standard.
Google Chrome 26+
Full support
Mozilla Firefox 16+
Full support
Apple Safari 9+
Full support
Microsoft Edge 12+
Full support
Opera 12.1+
Full support
Samsung Internet 1.5+
Full support
Internet Explorer 10+
Full support transition-duration Widely supported
Bottom line: Safe to teach and ship for s/ms durations. Prefer unprefixed standard syntax in modern code. It is not a runtime API.
Remember
Key Takeaways Role: set how long a transition takes to complete.
Initial value: 0s — no visible animation until you raise it.
Units: s or ms only; unitless 0 is invalid.
Lists: multiple times map to transition-property in order.
One line: without a positive transition-duration, every transition is instant — set s or ms to make the change visible.
Frequently Asked Questions What does the CSS transition-duration property do? It sets how long a CSS transition takes to complete after it starts. The default 0s means the change is instant.
What units can I use? Use <time> values with a unit: seconds (s) or milliseconds (ms). Example: 0.3s or 300ms. Unitless 0 is invalid — write 0s.
What is the difference between duration and delay? transition-duration is how long the change runs. transition-delay is how long to wait before it starts.
Can I set different durations for different properties? Yes. List multiple times separated by commas. They map in order to the properties in transition-property.
Are negative durations allowed? No. A negative time makes the declaration invalid.
Which browsers support transition-duration? It is Baseline Widely available across modern browsers. It is a browser CSS property, not a Node.js feature.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion