Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
* Some parts of this feature may have varying levels of support.
The animation shorthand CSS property applies an animation between styles. It is a shorthand for animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, animation-play-state, and animation-timeline.
This property is a shorthand for the following CSS properties:
One or more single <animation> declarations, separated by commas, with each <animation> including:
<keyframes-name> or noneThe name of a @keyframes at-rules that specifies the animation to apply to an element. The initial value for animation-name is none.
<animation-duration>Determines the length of time that an animation takes to complete one cycle. The value must be one of those available in animation-duration. The initial value is 0s.
<easing-function>Determines the type of transition. The value must be one of those available in animation-timing-function. The initial value is ease.
<animation-delay>Determines the amount of time to wait from applying the animation to an element before beginning to perform the animation. The value must be one of those available in animation-delay. The initial value is 0s.
<single-animation-direction>The direction in which the animation is played. The value must be one of those available in animation-direction. The initial value for animation-direction is normal.
<single-animation-iteration-count>The number of times the animation is played. The value must be one of those available in animation-iteration-count. The initial value for animation-iteration-count is 1.
<single-animation-fill-mode>Determines how styles should be applied to the animation's target before and after its execution. The value must be one of those available in animation-fill-mode. The initial value for animation-fill-mode is none.
<single-animation-play-state>Determines whether the animation is playing or not. The value must be one of those available in animation-play-state. The initial value for animation-play-state is running.
<single-animation-timeline>Determines the timeline used to control the progress of the animation. The value must be one of those available in animation-timeline. The initial value is auto.
The animation property is specified as one or more single animations, separated by commas. Each animation within the comma-separated list of animations sets the animation-name, animation-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-fill-mode, animation-play-state, and animation-timeline. If any of the components are not included in an animation declaration, the component value is set to the component's initial value.
The <animation-name> component of each animation is the name for the animation, which may be none, a <custom-ident>, or a <string>. The initial value of animation-name is none, meaning if no animation-name value is declared in the animation shorthand property, no animation is applied to any of the properties.
The order of other values within an animation definition is important for distinguishing an animation-name value from other values. If a value in the animation shorthand can be parsed as a value for an animation property other than animation-name, then the value will be applied to that property first and not to animation-name. For this reason, the recommended practice is to specify a value for animation-name as the last value in a list of values when using the animation shorthand; this holds true even when you specify multiple, comma-separated animations using the animation shorthand.
Each animation can include zero, one, or two occurrences of the <time> value. The order of time values within each animation definition is important: the first value that can be parsed as a <time> is assigned to the animation-duration, and the second one is assigned to animation-delay.
When no animation-duration value is specified in the animation shorthand property, the duration defaults to 0s. In this case, the animation will still occur (the animationStart and animationEnd events will be fired), but no animation will be visible to the user.
If no <animation-timeline> is included in the animation shorthand, the shorthand declaration will reset any previously-declared animation-timeline values to auto, which sets the timeline to the default documentTimeline.
If an <animation-timeline> value is included, but the user-agent doesn't support <animation-timeline> values within the shorthand, the entire animation declaration is invalid and ignored. For this reason, when creating CSS scroll-driven animations, you need to declare the animation-timeline property after declaring any animation shorthand for it to take effect.
Alternatively, the <animation-timeline> can be set within the animation shorthand within a CSS @supports block, such as:
In the case of the animation-fill-mode forwards value, animated properties behave as if included in a set will-change property value. If a new stacking context is created during the animation, the target element retains the stacking context after the animation has finished.
Blinking and flashing animation can be problematic for people with cognitive concerns such as Attention Deficit Hyperactivity Disorder (ADHD). Additionally, certain kinds of motion can be a trigger for vestibular disorders, epilepsy, and migraine and scotopic sensitivity.
Consider providing a mechanism for pausing or disabling animation as well as using the reduced motion @media query to create a complimentary experience for users who have expressed a preference for reduced animated experiences.
as each of the properties of the shorthand:
|
| all elements |
| no |
as each of the properties of the shorthand:
|
| Not animatable |
Note: Animating CSS box model properties is discouraged as it leads to layout reflow and repaints. Animating any box model property is inherently CPU-intensive; consider animating the transform property instead.
In this example, we demonstrate basic usage of the animate shorthand by animating a yellow sun across a light blue sky. The sun rises to the center of the viewport and then falls out of sight.
We include a single <div> element to represent our sun.
We start by creating the sun and the sky. The sky is the :root of the HTML document. We hide any content that is outside the viewport, which in our case will be any part of the sun below the horizon, by setting the overflow to hidden. We also use the justify-content property to center the sun in the background. We make the sun yellow, declare its height to be the height of the viewport (100vh), and set its width to equal its height by setting the aspect-ratio to 1. We turn the square <div> into a circle using the border-radius property.
Next, we define some animation @keyframes that will push the element on which they are applied down past the viewport and then return the element to its default position using CSS transforms:
The last step is to apply the animation! We use the animation shorthand property to apply the sunrise keyframe animation to the .sun <div>. The animation is set to play for infinite iterations, with each one lasting 4 seconds; the animation direction alternates with each iteration:
This example demonstrates applying multiple animations to a single element. Expanding on the previous example, with a sun that rises and falls on a light blue background, here we will gradually rotate the sun through a rainbow of colors. The timing of the sun's position and color are independent.
We include the same HTML and CSS as in the previous example, and add a second set of animation @keyframes to apply a filter that rotates the hue through all possible values using the hue-rotate() filter function:
We then apply the two animations to our sun. Multiple animations are separated by commas, and each animation's parameters are set independently:
This example demonstrates what happens when multiple animations define values for the same property. This example expands upon the basic usage example, with two animations applied that both set a transform value.
We use the same HTML and CSS as in the first example, including the original sunrise animation, and a second animation named bounce. The two animations declare values for the same property:
We apply both animations to the sun. When two animations apply different values to the same property, animations declared later in the cascade override previously-declared animations. In this case, the transform value on the bounce animation "wins" the cascade, and overrides the transform set by sunrise, so the sun will only move horizontally.
The sun bounces between the left- and right-hand sides of the viewport. The sun remains in the viewport even though the sunrise animation is defined. The sunrise animation's transform property is overridden by the bounce animation.
| CSS Animations Level 1 # animation |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 11, 2026 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.