The Element.animate() method is a Web Animations API shortcut: it creates a new Animation, applies it to the element, plays it, and returns the Animation instance (MDN).
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.animate. Start with this line.
JavaScript
el.animate(keyframes, options)
Call
What it does
el.animate(keyframes, options)
Primary signature.
el.animate(...)
Call with the arguments your case needs.
Built into the browser. Call animate(...) on an Element — no import required.
Library declarations
JavaScript
el.animate(keyframes, options)
Parameters
Parameter
Description
keyframes
Required. What properties change over time
options
Required. Duration (number) or timing object
Return Value
Return Value
Description
*
Animation (already playing)
JavaScript Examples
Example 1 — Basic Keyframes
Rotate and scale an element with an options object.
Store the return value.animate() gives you an Animation.
Loop if needed.iterations: Infinity keeps it running.
Pause. Stops playback without removing the effect immediately.
Cancel. Stops and clears the animation effect.
Compatibility
Browser Support
Element.animate() is Baseline Widely available on MDN (across browsers since March 2020). It is not Deprecated, Experimental, or Non-standard. Core keyframes + timing are widely supported; timeline / animation-range options may need feature detection.
✓ Baseline Widely available
Element.animate()
Web Animations API shortcut — create, apply, and play. Widely available since 2020.
2020+Widely available
Google Chrome36+
Supported
Mozilla Firefox48+
Supported
Apple Safari13.1+
Supported
Microsoft Edge79+
Supported
Opera23+
Supported
Internet ExplorerNot supported
Unavailable
animate()Baseline
Bottom line: Safe for modern browsers. Prefer CSS animations or a fallback for very old IE.
Frequently Asked Questions
It is a Web Animations API shortcut: it creates a new Animation, applies it to the element, plays it, and returns the Animation object so you can pause, cancel, or await finish (MDN).
No. MDN marks Element.animate() as Baseline Widely available (across browsers since March 2020). It is not Deprecated, Experimental, or Non-standard. Some options like scroll timeline ranges may have narrower support.
An Animation instance. Keep the reference if you need play(), pause(), cancel(), finished, or playbackRate.
Yes. Passing a number is treated as duration in milliseconds — for example el.animate(keyframes, 1000).
Yes. You can call animate() several times. Use Element.getAnimations() to list animations that currently affect the element.
CSS animations are declarative in stylesheets. animate() creates the same kind of animation from JavaScript with a returned Animation you can control in code.