The animation property plays a @keyframes sequence on an element. One line can set how long it runs, how it eases, and whether it repeats or stays at the end.
Not deprecated. The shorthand has been widely available since 2015. A scroll animation-timeline inside animation is not reliable: Chrome only resets it, and other browsers can drop the whole declaration.
Syntax
CSS Syntax
syntax.css
animation:1sease-in-outinfinitealternatefade;
The first time is the duration. A second time is the delay. Put the @keyframes name last.
Values
Property Values
Any piece you leave out uses its initial value. The initial animation is none, with a duration of 0s.
Value
Description
Try it
1s
Duration. The first time value. 0s runs, but you cannot see it
Play the fade. One second, from opacity 1 to 0.25.
Keep the last frame.forwards holds the to style after the play ends.
The count is still one. Nothing here says infinite.
Drop forwards and it snaps. Fill mode none throws away the animated opacity and restores the normal style.
Edge Cases & Pitfalls
If nothing moves, the time or the name is usually the reason.
0s
No duration means nothing to see
animation: fade uses the initial duration, 0s. The animation still starts and ends, but the fade is invisible.
time
The first time is the duration
animation: 1s 2s fade plays for 1 second after a 2 second wait. The second time is the delay.
name
Put the keyframe name last
A value that can be a keyword, such as ease or forwards, is taken by that piece. A custom name at the end is left for @keyframes.
end
It snaps back unless you say forwards
The initial fill mode is none. The element keeps the last keyframe only when the shorthand includes forwards or both.
motion
Some people need the motion turned off
A fast loop can be hard to read. prefers-reduced-motion is how a visitor asks for less motion. Do not put an animation-timeline keyword in this shorthand. Set that property on its own line after animation.
Compatibility
Browser Support
animation is a browser style property. Node.js, Deno, and Bun do not play it. The versions below are the unprefixed shorthand.
✓ Baseline · Widely available since 2015
animation
Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, Internet Explorer 10+. A timeline keyword inside the shorthand is a separate, newer feature.
97%unprefixed shorthand
Google Chrome43+
Full support
Mozilla Firefox16+
Full support
Apple Safari9+
Full support
Microsoft Edge12+
Full support
Opera30+
Full support
Samsung Internet4+
Full support
Internet Explorer10+
Full support
animationWidely supported
Bottom line: Older Chrome, Safari, and Firefox also accepted a prefixed shorthand. Putting animation-timeline inside animation is Chrome 115 reset-only, and Firefox and Safari do not support that keyword here.
Remember
Key Takeaways
Role: one shorthand that plays a named @keyframes sequence.
Time: the first time is the duration. The second time is the delay.
Name last:animation: 1s infinite alternate fade.
forwards: keep the last frame. Without it, the element snaps back.
One line: define @keyframes, then play it with a duration and the name at the end.
Frequently Asked Questions
It plays a named @keyframes sequence on an element. One declaration can set the duration, easing, delay, repeat count, direction, fill mode, and play state.
Yes. animation only points at a name. The steps live in @keyframes with that same name. animation: none turns the animation off.
The initial fill mode is none, so the element returns to its normal style when the animation ends. Add forwards to keep the last keyframe.
The first time is the duration. The second time is the delay. animation: 1s 2s fade plays for 1 second after waiting 2 seconds.
Chrome 43+, Firefox 16+, Safari 9+, Edge 12+, and Internet Explorer 10 support the unprefixed shorthand. It is a browser style property, not a Node.js feature.