CSS propertyTransitions
transition-delay
Sets how long after a value change the transition starts.
- Initial value
0s- Inherited
- No
- Animatable
- no
- Applies to
- all elements and the ::before and ::after pseudo-elements
- JavaScript
element.style.transitionDelay = "0.2s"
Example
#CSS
.tooltip {
opacity: 0;
transition: opacity 0.2s;
}
.trigger:hover .tooltip {
opacity: 1;
transition-delay: 0.4s;
}Example HTML
<style>
.tip { opacity: 0; transition: opacity .2s; margin-left: 8px; color: #a78bfa; }
.tip-wrap:hover .tip { opacity: 1; transition-delay: .4s; }
</style>
<p class="tip-wrap stage" style="margin: 0">Hover and wait a moment <span class="tip">The tooltip appears with a delay</span></p>Preview
Definition and usage
#The transition-delay property delays the start of a transition. The value changes only after the given time has passed, and then animates according to transition-duration.
Delays let you choreograph motion: the colour changes first and the element moves a moment later, or successive menu items appear one after another.
A negative value starts the transition as if it had already been running for a while, so it begins partway through.
Syntax
#Syntax
transition-delay: <time> [, <time>]*;Values
#Values in practice
#0s
The transition starts immediately.
.demo { transition-delay: 0s; }0.5s
Half a second of waiting before the movement.
.demo { transition-delay: 0.5s; }0s, 0.5s
Movement starts immediately, the colour changes with a delay.
.demo { transition-delay: 0s, 0.5s; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- A short tooltip delay (300-500 ms) prevents it from flickering when the cursor merely passes over the element.
- Different delays for successive list items create a cascade effect.
Related entries
#Practise it in lessons
#Spotted a mistake or missing an example? Write to us.