The animation-direction property in CSS is used to define the direction of the animation. The direction of animation should be forwards, backward, or in alternate cycles.
Syntax:
animation-direction: normal|reverse|alternate|alternate-reverse|
initial|inherit;
Property Value: The animation-direction property are listed below:
- normal: This animation property plays the animation forward. It is the default value.
- reverse: This animation property plays the animation in the reverse direction.
- alternate: This animation property plays the animation forwards first, and then backward.
- alternate-reverse: This animation property play animation backwards first, and then forwards.
- initial: This property is used to set the animation property to its default value.
- inherit: This property is used to inherit the animation property from its parent element.
Example: In this example, we are using animation-direction: normal property.
html
<!DOCTYPE html>
< html >
< head >
< title >
CSS | animation-direction Property
</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
h3 {
width: 100%;
animation-name: text;
animation-duration: 2s;
animation-iteration-count: infinite;
}
#one {
animation-direction: normal;
}
@keyframes text {
from {
margin-left: 60%;
}
to {
margin-left: 0%;
}
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >animation-direction property</ h2 >
< h3 id = "one" >This text is normal.</ h3 >
</ body >
</ html >
|
Output:

Example: In this example, we are using animation-direction: reverse property.
html
<!DOCTYPE html>
< html >
< head >
< title >
CSS | animation-direction Property
</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
h3 {
width: 100%;
animation-name: text;
animation-duration: 2s;
animation-iteration-count: infinite;
}
#one {
animation-direction: reverse;
}
@keyframes text {
from {
margin-left: 60%;
}
to {
margin-left: 0%;
}
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >animation-direction property</ h2 >
< h3 id = "one" >This text is reverse.</ h3 >
</ body >
</ html >
|
Output:

Example: In this example, we are using animation-direction: alternate property.
html
<!DOCTYPE html>
< html >
< head >
< title >
CSS | animation-direction Property
</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
h3 {
width: 100%;
animation-name: text;
animation-duration: 2s;
animation-iteration-count: infinite;
}
#one {
animation-direction: alternate;
}
@keyframes text {
from {
margin-left: 60%;
}
to {
margin-left: 0%;
}
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >animation-direction property</ h2 >
< h3 id = "one" >This text is alternate.</ h3 >
</ body >
</ html >
|
Output:

Example: In this example, we are using animation-direction: alternate-reverse property.
html
<!DOCTYPE html>
< html >
< head >
< title >
CSS | animation-direction Property
</ title >
< style >
body {
text-align: center;
}
h1 {
color: green;
}
h3 {
width: 100%;
animation-name: text;
animation-duration: 2s;
animation-iteration-count: infinite;
}
#one {
animation-direction: alternate-reverse;
}
@keyframes text {
from {
margin-left: 60%;
}
to {
margin-left: 0%;
}
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >animation-direction property</ h2 >
< h3 id = "one" >This text is alternate-reverse.</ h3 >
</ body >
</ html >
|
Output:

Supported Browser: The browser supported by animation-direction properties is listed below:
- Google Chrome 43.0 and above
- Edge 12.0 and above
- Firefox 16.0 and above
- Opera 30.0 and above
- Safari 9.0 and above