CSS transition Property

Description

The transition CSS property is a fundamental tool for creating smooth and visually pleasing animations and transitions in web design. It allows you to specify how a particular CSS property should change over time when triggered by events like hovering, clicking, or state changes. By defining properties such as duration, timing function, delay, and the specific property to be animated, developers can achieve seamless transformations in elements, making user interactions more engaging and intuitive. Whether it's a simple fade-in effect or a complex transformation, the transition property enhances the user experience by providing a sense of continuity and responsiveness in web interfaces. Individual properties are: transition-property, transition-duration, transition-timing-function, and transition-delay.

Initial value
see individual properties
Applies to
All elements, :before and :after pseudo elements
Inherited
No
Computed value
See individual properties
Animatable
No
JavaScript syntax
object.style.transition

Interactive Demo

Hover over me
to see transition.

Syntax

transition: <single-transition> [ ',' <single-transition> ]* 

Values

<single-transition> = [ none | <single-transition-property> ] || <time> || <single-transition-timing-function> || <time>

Example

<div class="test">CSS transition property</div>
div {
   width: 100px; 
   height: 60px; 
   background-color: khaki; 
   color: black;
   border: 2px solid orange; 
}
div:hover {
   width: 300px;
   height: 250px; 
   background: CornflowerBlue;
}
.test {
   transition: width 2s ease 100ms, height 1s linear 2s, background 0s 4s ; 
}

Browser Support

The following table will show you the current browser support for the CSS transition property.

Desktop
Edge Chrome Firefox Opera Safari
12261612.19
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
261612.191.54.4

Last updated by CSSPortal on: 2nd January 2024