<style type="text/css">
  table.event-handlers {
    border-collapse: collapse;
  }
  table.event-handlers th,
  table.event-handlers td {
    padding: 0.2em 1em;
  }
  table.event-handlers td {
    border: 1px solid black;
  }
</style>

<pre class='metadata'>
Title: CSS Animations Level 1
Status: ED
Work Status: Refining
Shortname: css-animations
Level: 1
Group: csswg
TR: https://www.w3.org/TR/css-animations-1/
ED: https://drafts.csswg.org/css-animations/
Previous Version: https://www.w3.org/TR/2018/WD-css-animations-1-20181011/
Previous Version: https://www.w3.org/TR/2017/WD-css-animations-1-20171130/
Previous Version: https://www.w3.org/TR/2013/WD-css3-animations-20130219/
Previous Version: https://www.w3.org/TR/2012/WD-css3-animations-20120403/
Editor: Dean Jackson, Apple Inc., dino@apple.com, w3cid 42080
Editor: L. David Baron, Mozilla https://www.mozilla.org/, https://dbaron.org/, w3cid 15393
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/, w3cid 42199
Editor: Brian Birtles, Invited Expert, brian@birchill.co.jp, w3cid 43194
Former Editor: David Hyatt, Apple Inc.
Former Editor: Chris Marrin, Apple Inc.
Former Editor: Sylvain Galineau, Adobe, galineau@adobe.com
!Issues List: <a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=Animations&list_id=36653&product=CSS&query_format=advanced&resolution=---">In Bugzilla</a>

Abstract: This CSS module describes a way for authors to animate the values of CSS properties over time, using keyframes. The behavior of these keyframe animations can be controlled by specifying their duration, number of repeats, and repeating behavior.

Link Defaults: css-values-3 (type) <time>, cssom-1 (interface) cssstyledeclaration, dom-core-ls (interface) event, webidl (type) SyntaxError, css-position-3 (property) left
Ignored Terms: domstring, animationeventinit, event, eventinit, eventtarget, document
</pre>
<pre class="anchors">
url: https://dom.spec.whatwg.org/#constructing-events; type: dfn; text: event constructor;
urlPrefix: https://html.spec.whatwg.org/multipage/webappapis.html; type: dfn; spec: html
    text: event handlers
    text: event handler event type
    text: event handler content attributes
    text: event handler IDL attributes
urlPrefix: https://html.spec.whatwg.org/multipage/infrastructure.html; type: dfn; spec: html
    text: HTML elements
</pre>
<pre class="link-defaults">
spec:cssom-1; type:interface; text:CSSRule
spec:html; type:dfn; text:case-sensitive
spec:css-backgrounds-3; type:property; text:background-image
spec:css2; type:property; text:display
</pre>

<h2 id="intro">
Introduction</h2>

	<em>This section is not normative</em>

	CSS Transitions [[CSS3-TRANSITIONS]] provide a way to interpolate
	CSS property values when they change as a result of underlying
	property changes. This provides an easy way to do simple animation,
	but the start and end states of the animation are controlled by the
	existing property values, and transitions provide little control to
	the author on how the animation progresses.

	This proposal introduces defined animations, in which the author can
	specify the changes in CSS properties over time as a set of keyframes.
	Animations are similar to transitions in that they change the
	presentational value of CSS properties over time. The principal difference
	is that while transitions trigger implicitly when property values change,
	animations are explicitly executed when the animation properties are applied.
	Because of this, animations require explicit values for the properties
	being animated. These values are specified using animation keyframes,
	described below.

	Many aspects of the animation can be controlled, including how many times
	the animation iterates, whether or not it alternates between the begin and
	end values, and whether or not the animation should be running or paused.
	An animation can also delay its start time.

<h2 id="values">
Values</h2>

	This specification follows the <a href="https://www.w3.org/TR/CSS21/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]].
	Value types not defined in this specification are defined in CSS Values & Units [[!CSS-VALUES-3]].
	Other CSS modules may expand the definitions of these value types.

	In addition to the property-specific values listed in their definitions,
	all properties defined in this specification
	also accept the <a>CSS-wide keywords</a> keywords as their property value.
	For readability they have not been repeated explicitly.

<h2 id="animations">
Animations</h2>

	CSS Animations affect computed property values. This effect happens by
	adding a specified value to the CSS cascade ([[!CSS3CASCADE]]) (at the
	level for CSS Animations) that will produce the correct computed value
	for the current state of the animation. As defined in [[!CSS3CASCADE]],
	animations override all normal rules, but are overridden by !important
	rules.

	If at some point in time there are multiple animations specifying behavior
	for the same property, the animation which occurs last in the value
	of 'animation-name' will override the other animations at that point.

	An animation does not affect the computed value before the application of the
	animation (that is, when the 'animation-name' property is set on an element)
	or after it is removed. Furthermore, typically an animation does not affect
	the computed value before the animation delay has expired or after the end of
	the animation, but may do so depending on the 'animation-fill-mode' property.

	While running, the animation computes the value of those properties
	it animates. Other values may take precedence over the animated value
	according to the CSS cascade ([[!CSS3CASCADE]]).

	While an animation is applied but has not finished, or has finished but has
	an 'animation-fill-mode' of ''forwards'' or ''both'', the user agent must act
	as if the 'will-change' property ([[!css-will-change-1]]) on the element
	additionally includes all the properties animated by the animation.

	The start time of an animation is the time at which the style applying
	the animation and the corresponding @keyframes rule are both resolved.
	If an animation is specified for an element but the corresponding
	@keyframes rule does not yet exist, the animation cannot start; the
	animation will start from the beginning as soon as a matching @keyframes
	rule can be resolved. An animation specified by dynamically modifying the
	element's style will start when this style is resolved; that may be
	immediately in the case of a pseudo style rule such as hover, or may be
	when the scripting engine returns control to the browser (in the case of
	style applied by script). Note that dynamically updating keyframe style
	rules does not start or re-start an animation.

	An animation applies to an element if its name appears as one of the
	identifiers in the computed value of the 'animation-name' property and the
	animation uses a valid @keyframes rule. Once an
	animation has started it continues until it ends or the 'animation-name' is
	removed. Changes to the values of animation properties while the animation
	is running apply as if the animation had those values from when it
	began. For example, shortening the 'animation-delay' may cause the animation
	to jump forwards or even finish immediately and dispatch an
	{{animationend}} event.
	Conversely, extending the 'animation-delay' may cause an animation to
	re-start and dispatch an {{animationstart}} event.

	The same @keyframes rule name may be repeated within an 'animation-name'.
	Changes to the 'animation-name' update existing animations by iterating over
	the new list of animations from last to first, and, for each animation,
	finding the <em>last</em> matching animation in the list of existing
	animations.
	If a match is found, the existing animation is updated using the animation
	properties corresponding to its position in the new list of animations,
	whilst maintaining its current playback time as described above.
	The matching animation is removed from the existing list of animations such
	that it will not match twice.
	If a match is not found, a new animation is created.
	As a result, updating 'animation-name' from &lsquo;a&rsquo; to
	&lsquo;a, a&rsquo; will cause the existing animation for &lsquo;a&rsquo; to
	become the <em>second</em> animation in the list and a new animation will be
	created for the first item in the list.

	<div class='example'>
		<pre>
		div {
		  animation-name: diagonal-slide;
		  animation-duration: 5s;
		  animation-iteration-count: 10;
		}

		@keyframes diagonal-slide {

		  from {
		    left: 0;
		    top: 0;
		  }

		  to {
		    left: 100px;
		    top: 100px;
		  }

		}
		</pre>

		This will produce an animation that moves an element from (0, 0) to
		(100px, 100px) over five seconds and repeats itself nine times
		(for a total of ten iterations).

	</div>

	Setting the 'display' property to ''display/none'' will terminate any running animation applied
	to the element and its descendants. If an element has a 'display' of ''display/none'', updating
	'display' to a value other than ''display/none'' will start all animations applied to the element
	by the 'animation-name' property, as well as all animations applied to descendants
	with 'display' other than ''display/none''.

	While authors can use animations to create dynamically changing content, dynamically
	changing content can lead to seizures in some users. For information on how to avoid
	content that can lead to seizures, see Guideline 2.3: Seizures: Do not design content
	in a way that is known to cause seizures ([[!WCAG20]]).

	Implementations may ignore animations when the rendering medium is not interactive e.g. when printed.
	A future version of this specification may define how to render animations for these media.

<h2 id="keyframes">
Keyframes</h2>

	Keyframes are used to specify the values for the animating properties at various points
	during the animation. The keyframes specify the behavior of one cycle of the animation;
	the animation may iterate zero or more times.

	Keyframes are specified using the <dfn>@keyframes</dfn> at-rule,
	defined as follows:

	<pre>
		@keyframes = @keyframes <<keyframes-name>> { <<rule-list>> }

		<dfn>&lt;keyframes-name></dfn> = <<custom-ident>> | <<string>>

		<dfn>&lt;keyframe-block></dfn> = <<keyframe-selector>># { <<declaration-list>> }

		<dfn>&lt;keyframe-selector></dfn> = from | to | <<percentage>>
	</pre>

	The <<rule-list>> inside of ''@keyframes'' can only contain <<keyframe-block>> rules.

	The <<declaration-list>> inside of <<keyframe-block>> accepts any CSS property
	except those defined in this specification,
	but <em>does</em> accept the 'animation-timing-function' property
	and interprets it specially.
	None of the properties interact with the cascade
	(so using ''!important'' on them is invalid and will cause the property to be ignored).

	A ''@keyframes'' block has a name given by the <<custom-ident>> or <<string>> in its prelude.
	The two syntaxes are equivalent in functionality;
	the name is the value of the ident or string.
	As normal for <<custom-ident>>s and <<string>>s,
	the names are fully <a>case-sensitive</a>;
	two names are equal only if they are codepoint-by-codepoint equal.
	The <<custom-ident>> additionally excludes the ''animation-name/none'' keyword.

	<div class=example>
		For example, the following two ''@keyframes'' rules have the same name,
		so the first will be ignored:

		<pre class=lang-css>
		@keyframes foo { /* ... */ }
		@keyframes "foo" { /* ... */ }
		</pre>

		On the other hand,
		the following ''@keyframes'' rule's name is <em>different</em> from the previous two rules:

		<pre class=lang-css>
		@keyframes FOO { /* ... */ }
		</pre>

		The following ''@keyframes'' rules are invalid
		because they use disallowed <<custom-ident>> values:

		<pre class=lang-css>
		@keyframes initial { /* ... */ }
		@keyframes None { /* ... */ }
		</pre>

		However, those names <em>can</em> be specified with a <<string>>,
		so the following are both <em>valid</em>:

		<pre class=lang-css>
		@keyframes "initial" { /* ... */ }
		@keyframes "None" { /* ... */ }
		</pre>
	</div>

	The <<keyframe-selector>> for a <<keyframe-block>> consists of a comma-separated list of percentage values or the keywords ''from'' or ''to''. The selector is used to specify the percentage along the duration of the animation that the keyframe represents. The keyframe itself is specified by the block of property values declared on the selector. The keyword ''from'' is equivalent to the value ''0%''. The keyword ''to'' is equivalent to the value ''100%''.
	Values less than ''0%'' or higher than ''100%'' are invalid
	and cause their <<keyframe-block>> to be ignored.

	<span class="note">Note that the percentage unit specifier must be used on percentage values. Therefore, ''0'' is an invalid keyframe selector.</span>

	If a ''0%'' or ''from'' keyframe is not specified, then the user agent constructs a ''0%'' keyframe
	using the computed values of the properties being animated. If a ''100%'' or ''to'' keyframe is not
	specified, then the user agent constructs a ''100%'' keyframe using the computed values of the
	properties being animated.

	The <<keyframe-block>> contains properties and values. The properties
	defined by this specification are ignored in these rules, with the exception of
	'animation-timing-function', the behavior of which is described below. In addition, properties qualified with !important are invalid and ignored.

	If multiple ''@keyframes'' rules are defined with the same name,
	the last one in document order wins,
	and all preceding ones are ignored.

<div class='example'>
<pre>
div {
  animation-name: slide-right;
  animation-duration: 2s;
}

@keyframes slide-right {

  from {
    margin-left: 0px;
  }

  50% {
    margin-left: 110px;
    opacity: 1;
  }

  50% {
    opacity: 0.9;
  }

  to {
    margin-left: 200px;
  }

}
</pre>

The two 50% rules from above can also be combined into an equivalent single rule
as illustrated below:

<pre>

@keyframes slide-right {

  from {
    margin-left: 0px;
  }

  50% {
    margin-left: 110px;
    opacity: 0.9;
  }

  to {
    margin-left: 200px;
  }

}
</pre>
</div>

	To determine the set of keyframes, all of the values in the selectors are sorted in increasing order
	by time. The rules within the ''@keyframes'' rule then cascade; the properties of a keyframe may thus derive
	from more than one ''@keyframes'' rule with the same selector value.

	If a property is not specified for a keyframe, or is specified but invalid, the animation of that
	property proceeds as if that keyframe did not exist. Conceptually, it is as if a set of keyframes is
	constructed for each property that is present in any of the keyframes, and an animation is run
	independently for each property.

	<div class='example'>
		<pre>
		@keyframes wobble {
		  0% {
		    left: 100px;
		  }

		  40% {
		    left: 150px;
		  }

		  60% {
		    left: 75px;
		  }

		  100% {
		    left: 100px;
		  }
		}
		</pre>

		Four keyframes are specified for the animation named "wobble". In the first keyframe,
		shown at the beginning of the animation cycle, the value of the 'left' property being
		animated is ''100px''. By 40% of the animation duration, 'left' has animated to ''150px''.
		At 60% of the animation duration, 'left' has animated back to ''75px''. At the end of the
		animation cycle, the value of 'left' has returned to ''100px''. The diagram below shows
		the state of the animation if it were given a duration of ''10s''.

		<figure>
			<img src="./animation1.png" alt="">
			<figcaption>Animation states specified by keyframes</figcaption>
		</figure>
	</div>

	<p class="issue">
		This specification needs to define
		how the value is determined from the keyframes,
		like the section on
		<a href="https://drafts.csswg.org/css-transitions/#application">Application of transitions</a>
		does for CSS Transitions.
	</p>

<h3 id="timing-functions">
Timing functions for keyframes</h3>

	A keyframe style rule may also declare the timing function that is to be used as the animation
	moves to the next keyframe.

	<div class='example'>
		<pre>
		@keyframes bounce {

		  from {
		    top: 100px;
		    animation-timing-function: ease-out;
		  }

		  25% {
		    top: 50px;
		    animation-timing-function: ease-in;
		  }

		  50% {
		    top: 100px;
		    animation-timing-function: ease-out;
		  }

		  75% {
		    top: 75px;
		    animation-timing-function: ease-in;
		  }

		  to {
		    top: 100px;
		  }

		}
		</pre>

		Five keyframes are specified for the animation named "bounce". Between the first and second
		keyframe (i.e., between 0% and 25%) an ease-out timing function is used. Between the second
		and third keyframe (i.e., between 25% and 50%) an ease-in timing function is used. And so on.
		The effect will appear as an element that moves up the page 50px, slowing down as it reaches
		its highest point then speeding up as it falls back to 100px. The second half of the animation
		behaves in a similar manner, but only moves the element 25px up the page.
	</div>

	A timing function specified on the ''to'' or ''100%'' keyframe is ignored.

	See the 'animation-timing-function' property for more information.

<h3 id="animation-name">
The 'animation-name' property</h3>

	 The 'animation-name' property defines a list of animations that apply. Each name is used to select
	 the keyframe at-rule that provides the property values for the animation. If the name does not match
	 any keyframe at-rule, there are no properties to be animated and the animation will not execute.
	 Furthermore, if the animation name is <code>none</code> then there will be no animation. This can be
	 used to override any animations coming from the cascade. If multiple animations are attempting to
	 modify the same property, then the animation closest to the end of the list of names wins.

	Each animation listed by name should have a corresponding value for the other animation properties
	listed below. If the lists of values for the other animation properties do not have the same length,
	the length of the 'animation-name' list determines the number of items in each list examined when
	starting animations. The lists are matched up from the first value: excess values at the end are not
	used. If one of the other properties doesn't have enough comma-separated values to match the number of
	values of 'animation-name', the UA must calculate its used value by repeating the list of values until
	there are enough. This truncation or repetition does not affect the computed value.

	Note: This is analogous to the behavior of the 'background-*' properties, with
	'background-image' analogous to 'animation-name'.

	<pre class='propdef'>
	Name: animation-name
	Value: [ none | <<keyframes-name>> ]#
	Initial: none
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item either a case-sensitive <a>css identifier</a> or the keyword ''animation-name/none''
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	The values of 'animation-name' have the following meanings:

	<dl dfn-type=value dfn-for=animation-name>
		<dt><dfn>none</dfn>
		<dd>
			No keyframes are specified at all, so there will be no animation.
			Any other animations properties specified for this animation have no effect.

		<dt><dfn><<keyframes-name>></dfn>
		<dd>
			The animation will use the keyframes with the name specified by the <<keyframes-name>>,
			if they exist.
			If no ''@keyframes'' rule with that name exists, there is no animation.
	</dl>

<h3 id="animation-duration">
The 'animation-duration' property</h3>

	The 'animation-duration' property defines duration of a single animation cycle.

	<pre class='propdef'>
	Name: animation-duration
	Value: <<time>>#
	Initial: 0s
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item a duration
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

<dl>
<dt><dfn value for=animation-duration><<time>></dfn>
<dd>
The <<time>> specifies the length of time that an animation takes to complete one cycle.
A negative <<time>> is invalid.

If the <<time>> is ''0s'', like the initial value,
the keyframes of the animation have no effect,
but the animation itself still occurs instantaneously.
Specifically, start and end events are fired;
if 'animation-fill-mode' is set to ''backwards'' or ''both'',
the first frame of the animation,
as defined by 'animation-direction',
will be displayed during the 'animation-delay'.
After the 'animation-delay' the last frame of the animation,
as defined by 'animation-direction',
will be displayed if 'animation-fill-mode' is set to ''forwards'' or ''both''.
If 'animation-fill-mode' is set to ''animation-fill-mode/none''
the animation will have no visible effect.
</dd>
</dl>

<h3 id="animation-timing-function">
The 'animation-timing-function' property</h3>

	The 'animation-timing-function' property describes how the animation will
	progress between each pair of keyframes.
	Timing functions are defined in the separate CSS Easing Functions module
	[[!css-easing-1]].

	The <a spec=css-easing>input progress value</a> used is the percentage
	of the time elapsed between the current keyframe and the next keyframe
	<em>after</em> incorporating the effect of the 'animation-direction' property.

	During the 'animation-delay', the 'animation-timing-function' is not applied.

	Note: This definition is necessary because otherwise a <a spec=css-easing>step
	easing function</a> with a <a spec=css-easing>step position</a> of <a value
	spec=css-easing for="steps()">start</a> would produce a backwards fill equal
	to the top of the first step in the function.

	The <a spec=css-easing>output progress value</a> is used as the <var
	ignore>p</var> value when interpolating the property values between the
	current and next keyframe.

	<pre class='propdef'>
	Name: animation-timing-function
	Value: <<easing-function>>#
	Initial: ease
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item a computed <<easing-function>>
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	When specified in a keyframe,
	'animation-timing-function' defines
	the progression of the animation
	between the current keyframe
	and the next keyframe for the animating property
	in sorted keyframe selector order
	(which may be an implicit 100% keyframe).

<h3 id="animation-iteration-count">
The 'animation-iteration-count' property</h3>

	The 'animation-iteration-count' property specifies the number of times an animation cycle
	is played. The initial value is ''1'', meaning the animation will play from beginning to end
	once. This property is often used in conjunction with an
	'animation-direction' value of ''alternate'', which will cause the animation to play in
	reverse on alternate cycles.

	The time window during which the animation is active
	(<code>duration</code> x <code>iteration-count</code>)
	is known as the <dfn>active duration</dfn>.

	<pre class='propdef'>
	Name: animation-iteration-count
	Value: <<single-animation-iteration-count>>#
	Initial: 1
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item either a number or the keyword ''animation-iteration-count/infinite''
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	<dfn>&lt;single-animation-iteration-count></dfn> = infinite | <<number>>

	<dl dfn-type=value dfn-for=animation-iteration-count>
		<dt><dfn>infinite</dfn>
		<dd>
			The animation will repeat forever.

		<dt><dfn><<number>></dfn>
		<dd>
			<p>The animation will repeat the specified number of times.
			If the number is not an integer,
			the animation will end partway through its last cycle.
			Negative numbers are invalid.

			<p>A value of ''0'' is valid and, similar to an 'animation-duration'
			of ''0s'', causes the animation to occur instantaneously.
	</dl>

	If the animation has a duration of ''0s'', it will occur instantaneously for any
	valid value of 'animation-iteration-count', including ''infinite''.


<h3 id="animation-direction">
The 'animation-direction' property</h3>

	The 'animation-direction' property defines whether or not the animation should play in reverse
	on some or all cycles. When an animation is played in reverse the timing functions are also
	reversed. For example, when played in reverse an ''ease-in'' animation would appear to be an
	''ease-out'' animation.

	<pre class='propdef'>
	Name: animation-direction
	Value: <<single-animation-direction>>#
	Initial: normal
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item a keyword as specified
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	<dfn>&lt;single-animation-direction></dfn> = normal | reverse | alternate | alternate-reverse

	<dl dfn-type=value dfn-for=animation-direction>
		<dt><dfn>normal</dfn>
		<dd>
			All iterations of the animation are played as specified.

		<dt><dfn>reverse</dfn>
		<dd>
			All iterations of the animation are played in the reverse direction
			from the way they were specified.

		<dt><dfn>alternate</dfn>
		<dd>
			The animation cycle iterations that are odd counts are played in the
			normal direction, and the animation cycle iterations that are even
			counts are played in a reverse direction.

		<dt><dfn>alternate-reverse</dfn>
		<dd>
			The animation cycle iterations that are odd counts are played in the
			reverse direction, and the animation cycle iterations that are even
			counts are played in a normal direction.
	</dl>

	Note: For the purpose of determining whether an iteration is even or odd,
	iterations start counting from 1.


<h3 id="animation-play-state">
The 'animation-play-state' property</h3>

	The 'animation-play-state' property defines whether the animation is running or paused.

	<pre class='propdef'>
	Name: animation-play-state
	Value: <<single-animation-play-state>>#
	Initial: running
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item a keyword as specified
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	<dfn>&lt;single-animation-play-state></dfn> = running | paused

	<dl dfn-type=value dfn-for=animation-play-state>
		<dt><dfn>running</dfn>
		<dd>
			While this property is set to ''running'',
			the animation proceeds as normal.

		<dt><dfn>paused</dfn>
		<dd>
			While this property is set to ''paused'',
			the animation is paused.
			The animation continues to apply to the element with the progress it had made before being paused.
			When unpaused (set back to ''running''), it restarts from where it left off,
			as if the "clock" that controls the animation had stopped and started again.

			If the property is set to ''paused'' during the delay phase of the animation,
			the delay clock is also paused and resumes as soon as 'animation-play-state' is set back to ''running''.
	</dl>

<h3 id="animation-delay">
The 'animation-delay' property</h3>

	The 'animation-delay' property defines when the animation will start. It allows an animation
	to begin execution some time after it is applied,
	or to appear to have begun execution some time <em>before</em> it is applied.

	<pre class='propdef'>
	Name: animation-delay
	Value: <<time>>#
	Initial: 0s
	Applies to: all elements
	Inherited: no
	Animation type: not animatable
	Percentages: N/A
	Computed value: list, each item a duration
	Canonical order: per grammar
	</pre>

	<dl>
		<dt><dfn value for=animation-delay><<time>></dfn>
		<dd>
			The <<time>> defines how long of a delay there is between the start of the animation
			(when the animation is applied to the element via these properties)
			and when it begins executing.
			A delay of ''0s'' (the initial value) means that the animation will execute as soon as it is applied.

			A negative delay is <strong>valid</strong>.
			Similar to a delay of ''0s'', it means that the animation executes immediately,
			but is automatically progressed by the absolute value of the delay,
			as if the animation had started the specified time in the past,
			and so it appears to start partway through its
			<a href="#animation-iteration-count">active duration</a>.
			If an animation's keyframes have an implied starting value,
			the values are taken from the time the animation starts,
			not some time in the past.
	</dl>

<h3 id="animation-fill-mode">
The 'animation-fill-mode' property</h3>

	The 'animation-fill-mode' property defines what values are applied by the animation
	outside the  time it is executing. By default, an animation will not affect property
	values between the time it is applied (the 'animation-name' property is set on an
	element) and the time it begins execution (which is determined by the 'animation-delay'
	property). Also, by default an animation does not affect property values after the
	animation ends (determined by the 'animation-duration' and 'animation-iteration-count' properties).
	The 'animation-fill-mode' property can override this behavior. Dynamic updates to the property will
	be reflected by property values as needed, whether during the animation delay or after the animation ends.

	<pre class='propdef'>
	Name: animation-fill-mode
	Value: <<single-animation-fill-mode>>#
	Initial: none
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: list, each item a keyword as specified
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	<dfn>&lt;single-animation-fill-mode></dfn> = none | forwards | backwards | both

	<dl dfn-type=value dfn-for=animation-fill-mode>
		<dt><dfn>none</dfn>
		<dd>
			The animation has no effect when it is applied but not executing.

		<dt><dfn>forwards</dfn>
		<dd>
			After the animation ends (as determined by its 'animation-iteration-count'), the animation
			will apply the property values for the time the animation ended. When 'animation-iteration-count'
			is an integer greater than zero, the values applied will be those for the end of the last
			completed iteration of the animation (rather than the values for the start of the iteration
			that would be next). When 'animation-iteration-count' is zero, the values applied will be
			those that would start the first iteration (just as when 'animation-fill-mode' is ''animation-fill-mode/backwards'').

		<dt><dfn>backwards</dfn>
		<dd>
			During the period defined by 'animation-delay', the animation will apply the property values
			defined in the keyframe that will start the first iteration of the animation.
			These are either the values of the ''from'' keyframe (when 'animation-direction' is ''animation-direction/normal''
			or ''animation-direction/alternate'') or those of the ''to'' keyframe (when 'animation-direction' is ''animation-direction/reverse''
			or ''animation-direction/alternate-reverse'').

		<dt><dfn>both</dfn>
		<dd>
			The effects of both ''animation-fill-mode/forwards'' and ''animation-fill-mode/backwards'' fill apply.
	</dl>

<h3 id="animation">
The 'animation' shorthand property</h3>

	The 'animation' shorthand property is a comma-separated list of animation definitions. Each item in
	the list gives one item of the value for all of the subproperties of the shorthand, which are known
	as the animation properties. (See the definition of 'animation-name' for what happens when these
	properties have lists of different lengths, a problem that cannot occur when they are defined using
	only the 'animation' shorthand.)

	<pre class='propdef'>
	Name: animation
	Value: 	<<single-animation>>#
	Initial: see individual properties
	Applies to: all elements
	Inherited: no
	Percentages: N/A
	Computed value: see individual properties
	Animation type: not animatable
	Canonical order: per grammar
	</pre>

	<dfn>&lt;single-animation></dfn> = <<time>> || <<easing-function>> || <<time>> || <<single-animation-iteration-count>> || <<single-animation-direction>> || <<single-animation-fill-mode>> || <<single-animation-play-state>> || [ none | <<keyframes-name>> ]

	Note that order is important within each animation definition: the first value in each
	<<single-animation>> that can be parsed as a <<time>> is assigned to the 'animation-duration',
	and the second value in each <<single-animation>> that can be parsed as a <<time>> is assigned to
	'animation-delay'.

	Note that order is also important within each animation definition for distinguishing
	<<keyframes-name>> values from other keywords. When parsing, keywords that are valid for
	properties other than 'animation-name'
	whose values were not found earlier in the shorthand
	must be accepted for those properties rather than for
	'animation-name'. Furthermore, when serializing, default values of other properties must be
	output in at least the cases necessary to distinguish an 'animation-name' that could
	be a value of another property, and may be output in additional cases.

	<div class="example">
		For example, a value parsed from ''animation: 3s none backwards''
		(where 'animation-fill-mode' is ''animation-fill-mode/none''
		and 'animation-name' is ''animation-name/backwards'')
		must not be serialized as ''animation: 3s backwards''
		(where 'animation-fill-mode' is ''animation-fill-mode/backwards''
		and 'animation-name' is ''animation-name/none'').
	</div>

<h2 id="events">
Animation Events</h2>

	Several animation-related events are available through the DOM Event system. The start and
	end of an animation, and the end of each iteration of an animation, all generate DOM events.
	An element can have multiple properties being animated simultaneously. This can occur either
	with a single 'animation-name' value with keyframes containing multiple properties, or with
	multiple 'animation-name' values. For the purposes of events, each 'animation-name' specifies
	a single animation. Therefore an event will be generated for each 'animation-name' value and
	not necessarily for each property being animated.

	Any animation for which a valid keyframe rule is defined will run
	and generate events; this includes animations with empty keyframe rules.

	The time the animation has been running is sent with each event generated. This allows the event
	handler to determine the current iteration of a looping animation or the current position of an
	alternating animation. This time does not include any time the animation was in the ''paused''
	play state.

<h3 id="interface-animationevent">
The <code>AnimationEvent</code> Interface</h3>

	The <code>AnimationEvent</code> interface provides specific contextual information associated with
	Animation events.

<h4 id="interface-animationevent-idl">
IDL Definition</h4>

	<pre class="idl">
		[Exposed=Window]
		interface AnimationEvent : Event {
		  constructor(CSSOMString type, optional AnimationEventInit animationEventInitDict = {});
		  readonly attribute CSSOMString animationName;
		  readonly attribute double elapsedTime;
		  readonly attribute CSSOMString pseudoElement;
		};
		dictionary AnimationEventInit : EventInit {
		  CSSOMString animationName = "";
		  double elapsedTime = 0.0;
		  CSSOMString pseudoElement = "";
		};
	</pre>

<h4 id="interface-animationevent-attributes">
Attributes</h4>

	<dl dfn-type=attribute dfn-for=AnimationEvent>
		<dt><dfn>animationName</dfn>
		<dd>
			The value of the 'animation-name' property of the animation that fired the event.
		<dt><dfn>elapsedTime</dfn>
		<dd>
			The amount of time the animation has been running, in seconds, when this event fired,
			excluding any time the animation was paused. The precise calculation for
			of this member is defined along with each event type.
		<dt><dfn>pseudoElement</dfn>
		<dd>
			The name (beginning with two colons) of the CSS pseudo-element on which the animation
			runs (in which case the target of the event is that pseudo-element's corresponding
			element), or the empty string if the animation runs on an element (which means the
			target of the event is that element).
	</dl>

	<dfn>AnimationEvent(type, animationEventInitDict)</dfn> is an <a>event constructor</a>.

<h3 id="event-animationevent">
Types of <code>AnimationEvent</code></h3>

	The different types of animation events that can occur are:

	<dl dfn-type=event dfn-for=animationevent>
		<dt><dfn>animationstart</dfn>
		<dd>
			The {{animationstart}} event occurs at the start of the animation.
			If there is an 'animation-delay' then this event will fire once the delay
			period has expired.
			<p>
			A negative delay will cause the event to fire with
			an {{AnimationEvent/elapsedTime}} equal to the absolute value of the delay
			capped to the <a>active duration</a> of the animation, that is,
			<code>min(max(-'animation-delay', 0), <a>active duration</a>)</code>; in
			this case the event will fire whether 'animation-play-state' is set to
			''running'' or ''paused''.
			</p>
			<ul>
				<li>Bubbles: Yes</li>
				<li>Cancelable: No</li>
				<li>Context Info: animationName, elapsedTime, pseudoElement</li>
			</ul>

		<dt><dfn>animationend</dfn>
		<dd>
			The {{animationend}} event occurs when the animation finishes.
			In this case the value of the {{AnimationEvent/elapsedTime}} member of
			the event is equal to the <a>active duration</a>.
			<ul>
				<li>Bubbles: Yes</li>
				<li>Cancelable: No</li>
				<li>Context Info: animationName, elapsedTime, pseudoElement</li>
			</ul>

		<dt><dfn>animationiteration</dfn>
		<dd>
			The {{animationiteration}} event occurs at the end of each iteration of an
			animation, except when an animationend event would fire at the same time.
			This means that this event does not occur for animations with an iteration
			count of one or less.

			<p>The {{AnimationEvent/elapsedTime}} member in this case is equal to the
			product of the <var>current iteration</var> and 'animation-duration' where
			the <var>current iteration</var> is the zero-based index of the new
			iteration. For example, assuming no negative 'animation-delay', after one
			iteration completes the <var>current iteration</var> would be one.</p>

			<ul>
				<li>Bubbles: Yes</li>
				<li>Cancelable: No</li>
				<li>Context Info: animationName, elapsedTime, pseudoElement</li>
			</ul>

		<dt><dfn>animationcancel</dfn>
		<dd>
			The {{animationcancel}} event occurs when the animation stops
			running in a way that does not fire an {{animationend}} event, such
			as a change in the 'animation-name' that removes the animation, or the
			animating element or one of its ancestors becoming ''display:none''.

			<p>The {{AnimationEvent/elapsedTime}} member for this event indicates
			the number of seconds that had elapsed since the beginning of the
			animation at the moment when the animation was canceled.
			This excludes any time where the animation was paused. If the animation
			had a negative 'animation-delay', the beginning of the animation is the
			moment equal to the absolute value of 'animation-delay' seconds
			<em>prior</em> to when the animation was actually triggered.
			Alternatively, if the animation had a positive 'animation-delay' and the
			event is fired before the animation's delay has expired, the
			{{AnimationEvent/elapsedTime}} will be zero.</p>

			<ul>
				<li>Bubbles: Yes</li>
				<li>Cancelable: No</li>
				<li>Context Info: animationName, elapsedTime, pseudoElement</li>
			</ul>
	</dl>


<h3 id="event-handlers-on-elements-document-objects-and-window-objects">Event
handlers on elements, <code>Document</code> objects, and <code>Window</code>
objects</h3>

The following are the <a>event handlers</a> (and their corresponding <a>event
handler event types</a>) that must be supported by all <a>HTML elements</a>, as
both <a>event handler content attributes</a> and <a>event handler IDL
attributes</a>; and that must be supported by all {{Document}} and {{Window}}
objects, as <a>event handler IDL attributes</a>:

<table class="event-handlers" dfn-type=attribute dfn-for="Document, Window">
  <tr>
    <th><a>Event handler</a></th>
    <th><a>Event handler event type</a></th>
  </tr>
  <tr>
    <td><dfn>onanimationstart</dfn></td>
    <td>{{animationstart}}</td>
  </tr>
  <tr>
    <td><dfn>onanimationiteration</dfn></td>
    <td>{{animationiteration}}</td>
  </tr>
  <tr>
    <td><dfn>onanimationend</dfn></td>
    <td>{{animationend}}</td>
  </tr>
  <tr>
    <td><dfn>onanimationcancel</dfn></td>
    <td>{{animationcancel}}</td>
  </tr>
</table>

<h2 id="interface-dom">
DOM Interfaces</h2>

	CSS animations are exposed to the CSSOM through a pair of new interfaces describing the keyframes.

    Note: the interfaces defined below reflect the interoperable API available as of this level of the specification. Future levels may deprecate parts of this API and extend others.

<h3 id="interface-cssrule">
The <code>CSSRule</code> Interface</h3>

	The following two rule types are added to the {{CSSRule}} interface. They provide
	identification for the new keyframe and keyframes rules.

<h4 id="interface-cssrule-idl">
IDL Definition</h4>

	<pre class="idl">
	partial interface CSSRule {
		  const unsigned short KEYFRAMES_RULE = 7;
		  const unsigned short KEYFRAME_RULE = 8;
	};
	</pre>

<h3 id="interface-csskeyframerule">
The <code>CSSKeyframeRule</code> Interface</h3>

	The {{CSSKeyframeRule}} interface represents the style rule for a single key.

<h4 id="interface-csskeyframerule-idl">
IDL Definition</h4>

	<pre class="idl">
	[Exposed=Window]
	interface CSSKeyframeRule : CSSRule {
    attribute CSSOMString keyText;
    [SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
	};
	</pre>

<h4 id="interface-csskeyframerule-attributes">
Attributes</h4>

  <dl dfn-type=attribute dfn-for=CSSKeyframeRule>

    <dt><dfn>keyText</dfn>
    <dd>
      This attribute represents the keyframe selector as a comma-separated list
      of percentage values. The ''from'' and ''to'' keywords map to 0% and 100%,
      respectively.

      If <a attribute for=CSSKeyframeRule>keyText</a> is updated with an
      invalid keyframe selector, a <a spec=webidl exception>SyntaxError</a>
      exception must be thrown and the value of <a attribute
      for=CSSKeyframeRule>keyText</a> must remain unchanged.
    </dd>

    <dt><dfn>style</dfn>
    <dd>
      Must return a {{CSSStyleDeclaration}} object for the
      keyframe rule, with the following properties:

      <dl>
        <dt><a spec=cssom for=CSSStyleDeclaration>readonly flag</a></dt>
        <dd>Unset.</dd>
        <dt><a spec=cssom for=CSSStyleDeclaration>declarations</a></dt>
        <dd>The declared declarations in the rule, in <a spec=cssom>specified
            order</a>.</dd>
        <dt><a spec=cssom for=CSSStyleDeclaration>parent CSS rule</a></dt>
        <dd>The <a>context object</a> (i.e. this {{CSSKeyframeRule}}).</dd>
        <dt><a spec=cssom for=CSSStyleDeclaration>owner node</a></dt>
        <dd>Null.</dd>
      </dl>
    </dd>
  </dl>

<h3 id="interface-csskeyframesrule">
The <code>CSSKeyframesRule</code> Interface</h3>

	The {{CSSKeyframesRule}} interface represents a complete set of keyframes for
	a single animation.

<h4 id="interface-csskeyframesrule-idl">
IDL Definition</h4>

	<pre class="idl">
	[Exposed=Window]
	interface CSSKeyframesRule : CSSRule {
	           attribute CSSOMString name;
	  readonly attribute CSSRuleList cssRules;

	  void             appendRule(CSSOMString rule);
	  void             deleteRule(CSSOMString select);
	  CSSKeyframeRule? findRule(CSSOMString select);
	};
	</pre>

<h4 id="interface-csskeyframesrule-attributes">
Attributes</h4>

	<dl dfn-type=attribute dfn-for=CSSKeyframesRule>

		<dt><dfn>name</dfn>
		<dd>
			This attribute is the name of the keyframes, used by the 'animation-name' property.

		<dt><dfn>cssRules</dfn>
		<dd>
			This attribute gives access to the keyframes in the list.
	</dl>

<h4 id="interface-csskeyframesrule-appendrule">
The <code>appendRule</code> method</h4>

	The <dfn method for="CSSKeyframesRule" lt="appendRule(rule)">appendRule</dfn> method appends the passed
	{{CSSKeyframeRule}} at the end of the keyframes rule.

	Parameters:

	<dl>

		<dt><dfn argument for="CSSKeyframesRule/appendRule(rule)">rule</dfn> of type {{CSSOMString}}
		<dd>
			The rule to be appended, expressed in the same syntax as one entry in the
			''@keyframes'' rule. A valid rule is always appended e.g. even if its key(s) already
			exists.
	</dl>

	No Return Value

	No Exceptions

<h4 id="interface-csskeyframesrule-deleterule">
The <code>deleteRule</code> method</h4>

The <dfn method for="CSSKeyframesRule" lt="deleteRule(select)">deleteRule</dfn> method
deletes the last declared {{CSSKeyframeRule}}
matching the specified keyframe selector.
If no matching rule exists, the method does nothing.

	Parameters:

	<dl>

		<dt><dfn argument for="CSSKeyframesRule/deleteRule(select)">select</dfn> of type {{CSSOMString}}
		<dd>
			The keyframe selector of the rule to be deleted: a comma-separated list of percentage values between 0% and 100% or the keywords ''from'' or ''to'' which resolve to 0% and 100%, respectively.

            The number and order of the values in the specified keyframe selector must match those of the targeted keyframe rule(s).  The match is not sensitive to white space around the values in the list.
	</dl>

	No Return Value

	No Exceptions


<h4 id="interface-csskeyframesrule-findrule">
The <code>findRule</code> method</h4>

	The <dfn method for="CSSKeyframesRule" lt="findRule(select)">findRule</dfn> returns the
    last declared {{CSSKeyframeRule}} matching the specified keyframe selector.
    If no matching rule exists, the method does nothing.

	Parameters:

	<dl>
		<dt><dfn argument for="CSSKeyframesRule/findRule(select)">select</dfn> of type {{CSSOMString}}
		<dd>
			The keyframe selector of the rule to be deleted: a comma-separated list of percentage values between 0% and 100% or the keywords ''from'' or ''to'' which resolve to 0% and 100%, respectively.

            The number and order of the values in the specified keyframe selector must match those of the targeted keyframe rule(s). The match is not sensitive to white space around the values in the list.
    </dl>

	Return Value:

	<dl>
		<dt>{{CSSKeyframeRule}}
		<dd>
			The found rule.
	</dl>

	No Exceptions

    <div class='example'>
        For example, given the following animation:
        <pre>

        @keyframes colorful-diagonal-slide {

          from {
            left: 0;
            top: 0;
          }

          10% {
            background-color: blue;
          }

          10% {
            background-color: green;
          }

          25%, 75% {
            background-color: red;
          }

          100% {
            left: 100px;
            top: 100px;
          }

        }
        </pre>

        Assuming the variable <code>anim</code> holds a reference to a CSSKeyframesRule object for this animation, then:

        <pre>
        anim.deleteRule('10%');
        var tenPercent = anim.findRule('10%');
        </pre>

        will start by deleting the last 10% rule i.e. the green background color rule; then find the remaining blue background rule and return it into <code>tenPercent</code>.

        The following:
        <pre>
        var red = anim.findRule('75%');
        </pre>

        will set <code>red</code> to <code>null</code>. The full selector for the red background color rule must be used instead:

        <pre>
        var red = anim.findRule('25%,75%');
        </pre>

        Since ''from'' maps to 0% and ''to'' maps to 100%, we can find these rules using either value:

        <pre>
        var from = anim.findRule('0%'); // Returns from { left: 0; top: 0; } rule
        var to = anim.findRule('to');   // Returns 100% { left: 100px; top: 100px; } rule
        </pre>
    </div>


<h3 id="interface-globaleventhandlers">
Extensions to the <code>GlobalEventHandlers</code> Interface Mixin</h3>

This specification extends the {{GlobalEventHandlers}} interface mixin from HTML to
add <a>event handler IDL attributes</a> for <a href="#events">animation
events</a> as defined in
[[#event-handlers-on-elements-document-objects-and-window-objects]].

<h4 id="interface-globaleventhandlers-idl">
IDL Definition</h4>

<pre class="idl">
partial interface mixin GlobalEventHandlers {
  attribute EventHandler onanimationstart;
  attribute EventHandler onanimationiteration;
  attribute EventHandler onanimationend;
  attribute EventHandler onanimationcancel;
};
</pre>


<h2 id="priv-sec">
Privacy and Security Considerations</h2>

This specification introduces no new privacy or security considerations.


<h2 id="acknowledgements">
Acknowledgements</h2>

	Thanks especially to the feedback from
	Tab Atkins,
	Brian Birtles,
	Shane Stephens,
	Carine Bournez,
	Christian Budde,
	Anne van Kesteren,
	Øyvind Stenhaug,
	Estelle Weyl,
	and all the rest of the www-style community.

<h2 id="other-open-issues">Other open issues</h2>

<p class="issue">Need to <a href="https://lists.w3.org/Archives/Public/www-style/2015Jul/0391.html">specify how keyframes interact</a>.</p>

<h2 id="wg-resolutions-pending">
Working Group Resolutions that are pending editing</h2>

	<em>This section is informative and temporary.</em>

	The editors are currently behind on editing this spec. The following working group resolutions still
	need to be edited in:

	<ul>
    	<li>2014-09-09 minutes (Antibes f2f)
    		<ul>
    		<li>Detail how/when keyframe values are computed; using <a href="http://lists.w3.org/Archives/Public/www-style/2014Aug/0132.html">G.beta in dbaron's mail</a>
    		<li><del>Agreed that both transitions and animations animate all properties. css-transitions to define animation of non-interoperable/discrete values. They take their starting values below 50% timing function progress, and end values above</del>
    		<li><del>Dynamic changes to animation properties/keyframes. Tab to propose resolution. (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14713">Bug 14713</a>)
    		<li><del>Negative animation-delay values apply against the active duration of the animation i.e. (animation-duration*animation-iteration-count). The delay can thus swallow iterations for which no iteration event will be fired. The start/end events are still fired. Even when delay == (-1*active_duration)
    		<li><del>Fire animation start/end events when animation-duration is zero, with 0 elapsedTime
    		<li><del>If animation-iteration-count is infinite and duration is 0, treat the iteration-count as if it was finite and run a 0s second (option A in <a href="http://lists.w3.org/Archives/Public/www-style/2014Sep/0056.html">Brian's mail</a>)
    		<li><del>If an animation with a negative animation delay is initially paused, the start event still fires
    		</ul>

    	<li>2012-10-29 minutes
	    	<ul>
        	<li><del>Change the animation properties to be dynamically changeable
        	<li><del>@keyframes can be dynamically changed
        	<li><del>When you encounter duplicate animations names, last one wins.</del>
        	<li><del>Make *animations* transition *all* properties. Unless otherwise specified, discrete properties take their starting values below 50% timing function progress, and end values above 50% timing function progress.</del>
        	</ul>
    	<li>2012-12-12 minutes and intermediate comments <del>and 2012-12-19 minutes</del>
    		<ul>
    		<li><del>Animations only run if they contain at least one valid keyframe rule (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=15251">Bug</a>)
    		<li><del>When an element changes from display:none to display: non-none, animations start immediately (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14785">Bug</a>)</del>
    		<li><del>An initially-paused animation is still started (fires start events etc.) (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14774">Bug</a>)
    		<li><del>Animations can be paused during their delay phase, which freezes the remaining delay to be applied after it unpauses (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14774">Bug</a>)</del>
    		<li><del>animation-play-state has the same list behavior as the other animation properties, matching the length of animation-name (<a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=14786">Bug</a>)</del>
    		</ul>
    	<li>2013-02-20 minutes
    		<ul>
    		<li><del>Øyvind's clarification accepted</del>
    		<li><del>keyframe rules cascade</del>
    		<li><del>mark pseudoElement at-risk</del>
    		</ul>
    	<li>2013-05-30 minutes
        	<ul>
        	<li><del>expectations on animations in non-interactive media</del>
        	</ul>
    	<li>2014-01-27 minutes
        	<ul>
        	<li><del>remove text about waiting for document load</del>
        	</ul>



