The CSS property that allows us to specify which properties should transition and how long the transition should take is the "transition" property. This property is used to create smooth and animated transitions between different states of an element.
The "transition" property is a shorthand property that combines several individual transition-related properties into one. These individual properties include "transition-property", "transition-duration", "transition-timing-function", and "transition-delay".
The "transition-property" property specifies the CSS properties that should transition. By default, all properties that can be animated using CSS transitions will transition. However, we can use this property to specify a comma-separated list of specific properties that we want to transition. For example:
css
div {
transition-property: width, height;
}
In this example, the width and height properties of the div element will transition when their values change.
The "transition-duration" property specifies the duration of the transition. It determines how long the transition should take to complete. The value can be specified in seconds (s) or milliseconds (ms). For example:
css
div {
transition-duration: 2s;
}
In this example, the transition will take 2 seconds to complete.
The "transition-timing-function" property specifies the timing function to be used for the transition. It determines how the intermediate property values are calculated during the transition. There are several predefined timing functions available, such as "ease", "linear", "ease-in", "ease-out", and "ease-in-out". We can also define our own custom timing functions using the cubic-bezier() function. For example:
css
div {
transition-timing-function: ease-in-out;
}
In this example, the transition will start slowly, accelerate in the middle, and then slow down again at the end.
The "transition-delay" property specifies a delay before the transition starts. It determines how long to wait before starting the transition after a property change has been detected. The value can be specified in seconds (s) or milliseconds (ms). For example:
css
div {
transition-delay: 1s;
}
In this example, the transition will start 1 second after a property change has been detected.
We can also combine all these individual properties into a single "transition" property using the shorthand syntax. For example:
css
div {
transition: width 2s ease-in-out 1s;
}
In this example, the width property will transition with a duration of 2 seconds, an ease-in-out timing function, and a delay of 1 second.
The "transition" property in CSS allows us to specify which properties should transition and how long the transition should take. By using the individual transition-related properties or the shorthand "transition" property, we can create smooth and animated transitions between different states of an element.
Other recent questions and answers regarding Creating transitions using CSS:
- How can you simplify the code for adding prefixes to CSS transitions for different browsers?
- What is the purpose of the transition-delay property in CSS?
- How can you control the timing function of a CSS transition?
- How can you create a smooth transition between two images when hovering over a box?

