CSS animation-direction Property

❮ Previous Reference Next ❯


div {
  animation-direction: alternate;


The animation-direction CSS property sets whether an animation should play forward, backward, or alternate back and forth between playing the sequence forward and backward.

Default value:normal
JavaScript syntax:

Standard Syntax

animation-direction: normal|reverse|alternate|alternate-reverse|initial|inherit|revert|revert-layer|unset;

Browser Support

The numbers in the table specify the first browser version that fully supports the property.


Property Values

The following table describes the values of this property:

Value Description
normal This is default. The animation should play forward in each cycle.
reverse The animation should play backward in each cycle.
alternate The animation plays forward in the first cycle, then play backward, then continues to alternate.
alternate-reverse The animation plays backward in the first cycle, then play forward, then continues to alternate.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.

Default CSS Property Values

selectors {
  animation-direction: normal;

More Example


div {
  width: 100px;
  height: 100px;
  background: red;
  position: relative;
  animation-iteration-count: infinite;
  animation-name: demo;
  animation-duration: 2s;
  animation-direction: alternate;

@keyframes demo {
  from {left: 0%;}
  to {left: 50%;}
❮ Previous Reference Next ❯