Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style animation Property

Style animation Property

Style Object Reference The Style object

Example

Use the shorthand property to change the

animation of an element:

document.getElementById("myDIV").style.animation="mymove 5s infinite";

Try it »


Definition and Usage

The animation property is a shorthand property for six animation properties:

animationName
animationDuration
animationTimingFunction
animationDelay
animationIterationCount
animationDirection.

**Note:** Always specify the animationDuration property, otherwise the duration is 0 and the animation will not play.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, and Opera support the animation property.

Safari and Chrome support an alternative to this property, namely the WebkitAnimation property.

**Note:** Internet Explorer 9 and earlier versions do not support the animation property.


Syntax

Return the animation property:

object

.style.animation

Set the animation property:

object

.style.animation="

name duration timingFunction delay iterationCount direction fillMode playState

"

Attribute values

Value Description
animationName Specifies the name of the keyframes to bind to the selector.
animationDuration Specifies the number of seconds or milliseconds the animation takes to complete.
animationTimingFunction Specifies the speed curve of the animation.
animationDelay Specifies the delay before the animation starts.
animationIterationCount Specifies the number of times the animation is played.
animationDirection Specifies whether the animation should alternate playing in reverse on alternate cycles.
animationFillMode Specifies the style to apply to the element when the animation is not playing (when it has finished, or when it has a delay and has not yet started).
animationPlayState Specifies whether the animation is running or paused.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: none 0 ease 0 1 normal none running
Return Value: A string representing the animation property of the element.
CSS version CSS3

Related Articles

CSS Reference Manual:animation Property


Style Object Reference The Style object