How to create a transition effect with CSS?

To create a transition effect, set the property for the transition effect. With that also set the duration of effect.

transition: height 5s;

You can try to run the following code to create a transition effect


Live demo

<!DOCTYPE html>
         div {
            width: 150px;
            height: 150px;
            background: blue;
            transition: width 3s;
         div:hover {
            width: 250px;
      <h1>Heading One</h1>
      <p>Hover over the below box to change its width.</p>