CSS Transitions

W3C Working Draft,

This version:
https://www.w3.org/TR/2018/WD-css-transitions-1-20181011/
Latest published version:
https://www.w3.org/TR/css-transitions-1/
Editor's Draft:
https://drafts.csswg.org/css-transitions/
Previous Versions:
Test Suite:
http://test.csswg.org/suites/css-transitions-1_dev/nightly-unstable/
Issue Tracking:
Bugzilla bugs for this level
Bugzilla bugs for all levels
GitHub Issues
Editors:
L. David Baron (Mozilla)
(Apple Inc)
(Mozilla)
Former Editors:
(Apple Inc)
(Apple Inc)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

CSS Transitions allows property changes in CSS values to occur smoothly over a specified duration.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

GitHub Issues are preferred for discussion of this specification. When filing an issue, please put the text “css-transitions” in the title, preferably like this: “[css-transitions] …summary of comment…”. All issues and comments are archived, and there is also a historical archive.

This document was produced by the CSS Working Group (part of the Style Activity).

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 1 February 2018 W3C Process Document.

This document is expected to be relatively close to last call. While some issues raised have yet to be addressed, new features are extremely unlikely to be considered for this level.

1. Introduction

This section is not normative.

This document introduces new CSS features to enable implicit transitions, which describe how CSS properties can be made to change smoothly from one value to another over a given duration.

2. Transitions

Normally when the value of a CSS property changes, the rendered result is instantly updated, with the affected elements immediately changing from the old property value to the new property value. This section describes a way to specify transitions using new CSS properties. These properties are used to animate smoothly from the old state to the new state over time.

For example, suppose that transitions of one second have been defined on the left and background-color properties. The following diagram illustrates the effect of updating those properties on an element, in this case moving it to the right and changing the background from red to blue. This assumes other transition parameters still have their default values.

Example showing the initial, intermediate, and final states of a box whose color and position is interpolated
Transitions of left and background-color.

Transitions are a presentational effect. The computed value of a property transitions over time from the old value to the new value. Therefore if a script queries the computed value of a property (or other data depending on it) as it is transitioning, it will see an intermediate value that represents the current animated value of the property.

The transition for a property is defined using a number of new properties. For example:

Example(s):

div {
  transition-property: opacity;
  transition-duration: 2s;
}
The above example defines a transition on the opacity property that, when a new value is assigned to it, will cause a smooth change between the old value and the new value over a period of two seconds.

Each of the transition properties accepts a comma-separated list, allowing multiple transitions to be defined, each acting on a different property. In this case, the individual transitions take their parameters from the same index in all the lists. For example:

Example(s):

div {
  transition-property: opacity, left;
  transition-duration: 2s, 4s;
}

This will cause the opacity property to transition over a period of two seconds and the left property to transition over a period of four seconds.

In the case where the lists of values in transition properties do not have the same length, the length of the transition-property list determines the number of items in each list examined when starting transitions. 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 transition-property, the user agent 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 transition-property.

Example(s):

div {
  transition-property: opacity, left, top, width;
  transition-duration: 2s, 1s;
}
The above example defines a transition on the opacity property of 2 seconds duration, a transition on the left property of 1 second duration, a transition on the top property of 2 seconds duration and a transition on the width property of 1 second duration.

While authors can use transitions 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]).

2.1. The transition-property Property

The transition-property property specifies the name of the CSS property to which the transition is applied.

Name: transition-property
Value: none | <single-transition-property>#
Initial: all
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: the keyword none else a list of identifiers
Canonical order: per grammar
Animation type: not animatable
<single-transition-property> = all | <custom-ident>;

A value of none means that no property will transition. Otherwise, a list of properties to be transitioned, or the keyword all which indicates that all properties are to be transitioned, is given.

If one of the identifiers listed is not a recognized property name, the implementation must still start transitions on the animatable properties in the list using the duration, delay, and timing function at their respective indices in the lists for transition-duration, transition-delay, and transition-timing-function. In other words, unrecognized properties must be kept in the list to preserve the matching of indices.

The <custom-ident> production in <single-transition-property> also excludes the keyword none, in addition to the keywords always excluded from <custom-ident>. This means that none, inherit, and initial are not permitted as items within a list of more that one identifier; any list that uses them is syntactically invalid.

For the keyword all, or if one of the identifiers listed is a shorthand property, implementations must start transitions for all its longhand sub-properties (or, for all, all properties), using the duration, delay, and timing function at the index corresponding to the shorthand.

If a property is specified multiple times in the value of transition-property (either on its own, via a shorthand that contains it, or via the all value), then the transition that starts uses the duration, delay, and timing function at the index corresponding to the last item in the value of transition-property that calls for animating that property.

Note: The all value and all shorthand property work in similar ways, so the all value is just like a shorthand that covers all properties.

2.2. The transition-duration Property

The transition-duration property defines the length of time that a transition takes.

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

This property specifies how long the transition from the old value to the new value should take. By default the value is 0s, meaning that the transition is immediate (i.e. there will be no animation). A negative value for transition-duration renders the declaration invalid.

2.3. The transition-timing-function Property

The transition-timing-function property describes how the intermediate values used during a transition will be calculated. It allows for a transition to change speed over its duration. These effects are commonly called easing functions.

Timing functions are defined in the separate CSS Easing Functions module [css-easing-1]. The input progress value used is the percentage of the transition duration, and the output progress value is used as the p value when interpolating the property value (see §4 Application of transitions).

Name: transition-timing-function
Value: <timing-function>#
Initial: ease
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: as specified
Canonical order: per grammar
Animation type: not animatable

2.4. The transition-delay Property

The transition-delay property defines when the transition will start. It allows a transition to begin execution some some period of time from when it is applied. A transition-delay value of 0s means the transition will execute as soon as the property is changed. Otherwise, the value specifies an offset from the moment the property is changed, and the transition will delay execution by that offset.

If the value for transition-delay is a negative time offset then the transition will execute the moment the property is changed, but will appear to have begun execution at the specified offset. That is, the transition will appear to begin part-way through its play cycle. In the case where a transition has implied starting values and a negative transition-delay, the starting values are taken from the moment the property is changed.

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

2.5. The transition Shorthand Property

The transition shorthand property combines the four properties described above into a single property.

Name: transition
Value: <single-transition>#
Initial: see individual properties
Applies to: all elements
Inherited: no
Percentages: N/A
Computed value: see individual properties
Canonical order: per grammar
Animatable: no
Animation type: not animatable
<single-transition> = [ none | <single-transition-property> ] || <time> || <timing-function> || <time>

Note that order is important within the items in this property: the first value that can be parsed as a time is assigned to the transition-duration, and the second value that can be parsed as a time is assigned to transition-delay.

If there is more than one <single-transition> in the shorthand, and any of the transitions has none as the <single-transition-property>, then the declaration is invalid.

3. Starting of transitions

Implementations must maintain a set of running transitions, each of which applies to a specific element and non-shorthand property. Each of these transitions also has a start time, end time, start value, end value, reversing-adjusted start value, and reversing shortening factor. Transitions are added to this set as described in this section, and are removed from this set when they complete or when implementations are required to cancel them. For the rationale behind the reversing-adjusted start value and reversing shortening factor, see §3.1 Faster reversing of interrupted transitions.

Implementations must also maintain a set of completed transitions, each of which (like running transitions) applies to a specific element and non-shorthand property. This specification maintains the invariant that there is never both a running transition and a completed transition for the same property and element.

If an element is no longer in the document, implementations must cancel any running transitions on it and remove transitions on it from the completed transitions.

This set of completed transitions needs to be maintained in order to prevent transitions from repeating themselves in certain cases, i.e., to maintain the invariant that this specification tries to maintain that unrelated style changes do not trigger transitions.

An example where maintaining the set of completed transitions is necessary would be a transition on an inherited property, where the parent specifies a transition of that property for a longer duration (say, transition: 4s text-indent) and a child element that inherits the parent’s value specifies a transition of the same property for a shorter duration (say, transition: 1s text-indent). Without the maintenance of this set of completed transitions, implementations could start additional transitions on the child after the initial 1 second transition on the child completes.

Various things can cause the computed values of properties on an element to change. These include insertion and removal of elements from the document tree (which both changes whether those elements have computed values and can change the styles of other elements through selector matching), changes to the document tree that cause changes to which selectors match elements, changes to style sheets or style attributes, and other things. This specification does not define when computed values are updated, beyond saying that implementations must not use, present, or display something resulting from the CSS cascading, value computation, and inheritance process [CSS3CASCADE] without updating the computed value (which means merely that implementations cannot avoid meeting requirements of this specification by claiming not to have updated the computed value as part of handling a style change). However, when an implementation updates the computed value of a property on an element to reflect one of these changes, or computes the computed value of a property on an element newly added to the document, it must update the computed value for all properties and elements to reflect all of these changes at the same time (or at least it must be undetectable that it was done at a different time). This processing of a set of simultaneous style changes is called a style change event. (Implementations typically have a style change event to correspond with their desired screen refresh rate, and when up-to-date computed style or layout information is needed for a script API that depends on it.)

Since this specification does not define when a style change event occurs, and thus what changes to computed values are considered simultaneous, authors should be aware that changing any of the transition properties a small amount of time after making a change that might transition can result in behavior that varies between implementations, since the changes might be considered simultaneous in some implementations but not others.

When a style change event occurs, implementations must start transitions based on the computed values that changed in that event. If an element is not in the document during that style change event or was not in the document during the previous style change event, then transitions are not started for that element in that style change event. Otherwise, define the before-change style as the computed values of all properties on the element as of the previous style change event, except with any styles derived from declarative animations such as CSS Transitions, CSS Animations ([CSS3-ANIMATIONS]), and SMIL Animations ([SMIL-ANIMATION], [SVG11]) updated to the current time. Likewise, define the after-change style as the computed values of all properties on the element based on the information known at the start of that style change event, but using the computed values of the animation-* properties from the before-change style, excluding any styles from CSS Transitions in the computation, and inheriting from the after-change style of the parent. Note that this means the after-change style does not differ from the before-change style due to newly created or canceled CSS Animations.

Note that this definition of the after-change style means that a single change can start a transition on the same property on both an ancestor element and its descendant element. This can happen when a property change is inherited from one element with transition-* properties that say to animate the changing property to another element with transition-* properties that also say to animate the changing property.

When this happens, both transitions will run, and the transition on the descendant will override the transition on the ancestor because of the normal CSS cascading and inheritance rules ([CSS3CASCADE]).

If the transition on the descendant completes before the transition on the ancestor, the descendant will then resume inheriting the (still transitioning) value from its parent. This effect is likely not a desirable effect, but it is essentially doing what the author asked for.

For each element with a before-change style and an after-change style, and each property (other than shorthands), define the matching transition-property value as the last value in the transition-property in the element’s after-change style that matches the property, as described in §2.1 The transition-property Property. If there is such a value, then corresponding to it, there is a matching transition duration, a matching transition delay, and a matching transition timing function in the values in the after-change style of transition-duration, transition-delay, and transition-timing-function (see the rules on matching lists). Define the combined duration of the transition as the sum of max(matching transition duration, 0s) and the matching transition delay.

When comparing the before-change style and after-change style for a given property, the property values are transitionable if they have an animation type that is neither not animatable nor discrete.

Note: Even if a property is defined to have an animation type that is not discrete, for a particular pair of property values the animation type may be discrete. For example, the animation type of the box-shadow property is shadow list, which defines that when the inset keyword is absent in one value but present in the other, discrete animation is used. As a result 0px 0px black and inset 10px 10px black are not transitionable.

For each element and property, the implementation must act as follows:

  1. If all of the following are true: then implementations must remove the completed transition (if present) from the set of completed transitions and start a transition whose:
  2. Otherwise, if the element has a completed transition for the property and the end value of the completed transition is different from the after-change style for the property, then implementations must remove the completed transition from the set of completed transitions.
  3. If the element has a running transition or completed transition for the property, and there is not a matching transition-property value, then implementations must cancel the running transition or remove the completed transition from the set of completed transitions.
  4. If the element has a running transition for the property, there is a matching transition-property value, and the end value of the running transition is not equal to the value of the property in the after-change style, then:
    1. If the current value of the property in the running transition is equal to the value of the property in the after-change style, or if these two values are not transitionable, then implementations must cancel the running transition.
    2. Otherwise, if the combined duration is less than or equal to 0s, or if the current value of the property in the running transition is not transitionable with the value of the property in the after-change style, then implementations must cancel the running transition.
    3. Otherwise, if the reversing-adjusted start value of the running transition is the same as the value of the property in the after-change style (see the section on reversing of transitions for why these case exists), implementations must cancel the running transition and start a new transition whose:
    4. Otherwise, implementations must cancel the running transition and start a new transition whose:

Note that the above rules mean that when the computed value of an animatable property changes, the transitions that start are based on the values of the transition-property, transition-duration, transition-timing-function, and transition-delay properties at the time the animatable property would first have its new computed value. This means that when one of these transition-* properties changes at the same time as a property whose change might transition, it is the new values of the transition-* properties that control the transition.

Example(s):

This provides a way for authors to specify different values of the transition-* properties for the “forward” and “reverse” transitions, when the transitions are between two states (but see below for special reversing behavior when an incomplete transition is interrupted). Authors can specify the value of transition-duration, transition-timing-function, or transition-delay in the same rule where they specify the value that triggers the transition, or can change these properties at the same time as they change the property that triggers the transition. Since it’s the new values of these transition-* properties that affect the transition, these values will be used for the transitions to the associated transitioning values. For example:

li {
  transition: background-color linear 1s;
  background: blue;
}
li:hover {
  background-color: green;
  transition-duration: 2s; /* applies to the transition *to* the :hover state */
}

When a list item with these style rules enters the :hover state, the computed transition-duration at the time that background-color would have its new value (green) is 2s, so the transition from blue to green takes 2 seconds. However, when the list item leaves the :hover state, the transition from green to blue takes 1 second.

Note that once the transition of a property has started (including being in its delay phase), it continues running based on the original timing function, duration, and delay, even if the transition-timing-function, transition-duration, or transition-delay property changes before the transition is complete. However, if the transition-property property changes such that the transition would not have started, the transition stops (and the property immediately changes to its final value).

Note that above rules mean that transitions do not start when the computed value of a property changes as a result of declarative animation (as opposed to scripted animation). This happens because the before-change style includes up-to-date style for declarative animations.

3.1. Faster reversing of interrupted transitions

Many common transitions effects involve transitions between two states, such as the transition that occurs when the mouse pointer moves over a user interface element, and then later moves out of that element. With these effects, it is common for a running transition to be interrupted before it completes, and the property reset to the starting value of that transition. An example is a hover effect on an element, where a transition starts when the pointer enters the element, and then the pointer exits the element before the effect has completed. If the outgoing and incoming transitions are executed using their specified durations and timing functions, the resulting effect can be distractingly asymmetric because the second transition takes the full specified time to move a shortened distance. Instead, this specification makes second transition shorter.

The mechanism the above rules use to cause this involves the reversing shortening factor and the reversing-adjusted start value. In particular, the reversing behavior is present whenever the reversing shortening factor is less than 1.

Note that these rules do not fully address the problem for transition patterns that involve more than two states.

Note that these rules lead to the entire timing function of the new transition being used, rather than jumping into the middle of a timing function, which can create a jarring effect.

This was one of several possibilities that was considered by the working group. See the reversing demo demonstrating a number of them, leading to a working group resolution made on 2013-06-07 and edits made on 2013-11-11.

4. Application of transitions

When a property on an element is undergoing a transition (that is, when or after the transition has started and before the end time of the transition) the transition adds a style called the current value to the CSS cascade at the level defined for CSS Transitions in [CSS3CASCADE].

Note that this means that computed values resulting from CSS transitions can inherit to descendants just like any other computed values. In the normal case, this means that a transition of an inherited property applies to descendant elements just as an author would expect.

Implementations must add this value to the cascade if and only if that property is not currently undergoing a CSS Animation ([CSS3-ANIMATIONS]) on the same element.

Note that this behavior of transitions not applying to the cascade when an animation on the same element and property is running does not affect whether the transition has started or ended. APIs that expose whether transitions are running (such as transition events) still report that a transition is running.

If the current time is at or before the start time of the transition (that is, during the delay phase of the transition), the current value is a specified style that will compute to the start value of the transition.

If the current time is after the start time of the transition (that is, during the duration phase of the transition), the current value is a specified style that will compute to the result of interpolating the property using the following values:

The specific interpolation procedure to be used is defined by the property’s animation type.

5. Completion of transitions

Running transitions complete at a time that is equal to or after their end time, but prior to to the first style change event whose time is equal to or after their end time. When a transition completes, implementations must move all transitions that complete at that time from the set of running transitions to the set of completed transitions and then fire the events for those completions. (Note that doing otherwise, that is, firing some of the events before doing all of the moving from running transitions to completed transitions, could allow a style change event to happen without the necessary transitions completing, since firing the event could cause a style change event, if an event handler requests up-to-date computed style or layout data.)

6. Transition Events

The creation, beginning, completion, and cancellation of CSS transitions generate corresponding DOM Events. An event is dispatched to the element for each property that undergoes a transition on that element. This allows a content developer to perform actions that synchronize with changes to transitions.

Each event provides the name of the property the transition is associated with as well as the duration of the transition.

6.1. Interface TransitionEvent

The TransitionEvent interface provides specific contextual information associated with transitions.

6.1.1. IDL Definition

[Exposed=Window,
 Constructor(CSSOMString type, optional TransitionEventInit transitionEventInitDict)]
interface TransitionEvent : Event {
  readonly attribute CSSOMString propertyName;
  readonly attribute double elapsedTime;
  readonly attribute CSSOMString pseudoElement;
};

dictionary TransitionEventInit : EventInit {
  CSSOMString propertyName = "";
  double elapsedTime = 0.0;
  CSSOMString pseudoElement = "";
};

6.1.2. Attributes

propertyName, of type CSSOMString, readonly

The name of the CSS property associated with the transition.

Note: This is always the name of a longhand property. See transition-property for how specifying shorthand properties causes transitions on longhands.

elapsedTime, of type double, readonly

The amount of time the transition has been running, in seconds, when this event fired not including any time spent in the delay phase. The calculation for of this member is defined along with each event type.

pseudoElement, of type CSSOMString, readonly

The name (beginning with two colons) of the CSS pseudo-element on which the transition occurred (in which case the target of the event is that pseudo-element’s corresponding element), or the empty string if the transition occurred on an element (which means the target of the event is that element).

TransitionEvent(type, transitionEventInitDict) is an event constructor.

6.2. Types of TransitionEvent

The different types of transition events that can occur are:

transitionrun
The transitionrun event occurs when a transition is created (i.e., when it is added to the set of running transitions).

A negative transition-delay will cause the event to fire with an elapsedTime equal to the absolute value of the delay capped to the transition-duration of the animation. That is, the elapsed time is equal to min(max(-transition-delay, 0), transition-duration).

  • Bubbles: Yes
  • Cancelable: No
  • Context Info: propertyName, elapsedTime, pseudoElement
transitionstart
The transitionstart event occurs when a transition’s delay phase ends.

The value of elapsedTime for transitionstart events is the same as the value used for transitionrun events.

  • Bubbles: Yes
  • Cancelable: No
  • Context Info: propertyName, elapsedTime, pseudoElement
transitionend
The transitionend event occurs at the completion of the transition. In the case where a transition is removed before completion, such as if the transition-property is removed, then the event will not fire.

The value of elapsedTime for this event is equal to the value of transition-duration.

  • Bubbles: Yes
  • Cancelable: No
  • Context Info: propertyName, elapsedTime, pseudoElement
transitioncancel
The transitioncancel event occurs when a transition is canceled.

The elapsedTime for transitioncancel events is the number of seconds from the end of the transition’s delay to the moment when the transition was canceled. If the transition had a negative transition-delay, the beginning of the transition is the moment equal to the absolute value of transition-delay seconds prior to when the transition was actually triggered. Alternatively, if the transition had a positive transition-delay and the event is fired before the transition’s delay has expired, the elapsedTime will be zero.

  • Bubbles: Yes
  • Cancelable: No
  • Context Info: propertyName, elapsedTime, pseudoElement

6.3. Event handlers on elements, Document objects, and Window objects

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

Event handler Event handler event type
ontransitionrun transitionrun
ontransitionstart transitionstart
ontransitionend transitionend
ontransitioncancel transitioncancel

7. DOM Interfaces

This specification extends the GlobalEventHandlers interface from HTML to add event handler IDL attributes for transition events as defined in §6.3 Event handlers on elements, Document objects, and Window objects.

7.1. IDL Definition

partial interface GlobalEventHandlers {
  attribute EventHandler ontransitionrun;
  attribute EventHandler ontransitionstart;
  attribute EventHandler ontransitionend;
  attribute EventHandler ontransitioncancel;
};

8. Security Considerations

This section is not normative.

The security implications of this specification are limited because it doesn’t allow Web content to do things that it could not do before. Rather, it allows things that could previously be done with script to be done declaratively, and it ways that implementations can optimize (for frame rate and CPU usage).

One of the major categories of optimizations that implementations can make is implementing animation of certain high-value properties (such as transform and opacity) run on a browser’s compositor thread or process without updating style or layout on the main Web content thread unless up-to-date style data are needed. This optimization often requires allocations of graphics memory to display the contents of the element being animated. Implementations should take care to ensure that Web content cannot trigger unsafe out-of-memory handling by using large numbers of animations or animations on elements covering large areas (where large may be defined in terms of pre-transform or post-transform size).

9. Privacy Considerations

This section is not normative.

As for security, the privacy considerations of this specification are limited because it does not allow Web content to do things that it could not do before.

This specification may provide additional mechanisms that help to determine characteristics of the user’s hardware or software. However, ability to determine performance characteristics of the user’s hardware or software is common to many Web technologies, and this specification does not introduce new capabilities.

As described in §10 Accessibility Considerations, implementations may provide mitigations to help users with disabilities. These mitigations are likely to be detectable by Web content, which means that users who would benefit from these mitigations may face a tradeoff between keeping their disability private from the Web content or benefiting from the mitigation.

10. Accessibility Considerations

This section is not normative.

10.1. Motion

This specification provides declarative mechanisms for animations that previously needed to be done using script. Providing a declarative mechanism has multiple effects: it makes such animations easier to make and thus likely to be more common, but it also makes it easier for user agents to modify those animations if such modifications are needed to meet a user’s accessibility needs.

Thus, users who are sensitive to movement, or who require additional time to read or understand content, may benefit from user agent features that allow animations to be disabled or slowed down. (But see §9 Privacy Considerations for information on the privacy implications of such mitigations.)

User agent implementors should be aware that Web content may depend on the firing of transition events, so implementations of such mitigations may wish to fire transition events even if the transitions were not run as continuous animations. However, it is probably poor practice for Web content to depend on such events to function correctly.

10.2. Cascade

The CSS cascade is a general mechanism in CSS that allows user needs to interact with author styles. This specification interacts with the cascade, but since it only allows animation between values that result from the existing cascade rules, it does not interfere with the user’s ability to force CSS properties to have particular values.

The cascade also allows users to disable transitions entirely by overriding the transition properties.

11. Changes since Working Draft of 30 November 2017

The following are the substantive changes made since the Working Draft dated 30 November 2017:

For more details on these changes, see the version control change log.

For changes in earlier working drafts:

  1. See the changes section in the 30 November 2017 Working Draft.

  2. See the changes section in the 19 November 2013 Working Draft.

  3. See the the ChangeLog for changes in previous working drafts.

  4. For more details on these changes, see the version control change logs, which are split in many parts because of file renaming:

12. Acknowledgments

Thanks especially to the feedback from Tab Atkins, Carine Bournez, Aryeh Gregor, Vincent Hardy, Anne van Kesteren, Cameron McCormack, Alex Mogilevsky, Jasper St. Pierre, Estelle Weyl, and all the rest of the www-style community.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Requirements for Responsible Implementation of CSS

The following sections define several conformance requirements for implementing CSS responsibly, in a way that promotes interoperability in the present and future.

Partial Implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported property values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Implementations of CR-level Features

Once a specification reaches the Candidate Recommendation stage, implementers should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec, and should avoid exposing a prefixed variant of that feature.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at https://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-CASCADE-4]
Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 4. 28 August 2018. CR. URL: https://www.w3.org/TR/css-cascade-4/
[CSS-COLOR-3]
Tantek Çelik; Chris Lilley; David Baron. CSS Color Module Level 3. 19 June 2018. REC. URL: https://www.w3.org/TR/css-color-3/
[CSS-EASING-1]
Brian Birtles; Dean Jackson; Matt Rakow. CSS Easing Functions Level 1. 9 October 2018. WD. URL: https://www.w3.org/TR/css-easing-1/
[CSS-TRANSFORMS-1]
Simon Fraser; et al. CSS Transforms Module Level 1. 30 November 2017. WD. URL: https://www.w3.org/TR/css-transforms-1/
[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. 14 August 2018. CR. URL: https://www.w3.org/TR/css-values-3/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. 14 August 2018. WD. URL: https://www.w3.org/TR/css-values-4/
[CSS2]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS2/
[CSS3-ANIMATIONS]
Dean Jackson; et al. CSS Animations Level 1. 30 November 2017. WD. URL: https://www.w3.org/TR/css-animations-1/
[CSS3CASCADE]
Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 3. 28 August 2018. CR. URL: https://www.w3.org/TR/css-cascade-3/
[CSSOM-1]
Simon Pieters; Glenn Adams. CSS Object Model (CSSOM). 17 March 2016. WD. URL: https://www.w3.org/TR/cssom-1/
[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[WEB-ANIMATIONS-1]
Brian Birtles; et al. Web Animations. 13 September 2016. WD. URL: https://www.w3.org/TR/web-animations-1/
[WebIDL]
Cameron McCormack; Boris Zbarsky; Tobie Langel. Web IDL. 15 December 2016. ED. URL: https://heycam.github.io/webidl/

Informative References

[CSS-BACKGROUNDS-3]
Bert Bos; Elika Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. 17 October 2017. CR. URL: https://www.w3.org/TR/css-backgrounds-3/
[SMIL-ANIMATION]
Patrick Schmitz; Aaron Cohen. SMIL Animation. 4 September 2001. REC. URL: https://www.w3.org/TR/smil-animation/
[SVG11]
Erik Dahlström; et al. Scalable Vector Graphics (SVG) 1.1 (Second Edition). 16 August 2011. REC. URL: https://www.w3.org/TR/SVG11/
[WCAG20]
Ben Caldwell; et al. Web Content Accessibility Guidelines (WCAG) 2.0. 11 December 2008. REC. URL: https://www.w3.org/TR/WCAG20/

Property Index

Name Value Initial Applies to Inh. %ages Ani­mat­able Anim­ation type Canonical order Com­puted value
transition <single-transition># see individual properties all elements no N/A no not animatable per grammar see individual properties
transition-delay <time># 0s all elements no N/A not animatable per grammar list, each item a duration
transition-duration <time># 0s all elements no N/A not animatable per grammar list, each item a duration
transition-property none | <single-transition-property># all all elements no N/A not animatable per grammar the keyword none else a list of identifiers
transition-timing-function <timing-function># ease all elements no N/A not animatable per grammar as specified

IDL Index

[Exposed=Window,
 Constructor(CSSOMString type, optional TransitionEventInit transitionEventInitDict)]
interface TransitionEvent : Event {
  readonly attribute CSSOMString propertyName;
  readonly attribute double elapsedTime;
  readonly attribute CSSOMString pseudoElement;
};

dictionary TransitionEventInit : EventInit {
  CSSOMString propertyName = "";
  double elapsedTime = 0.0;
  CSSOMString pseudoElement = "";
};

partial interface GlobalEventHandlers {
  attribute EventHandler ontransitionrun;
  attribute EventHandler ontransitionstart;
  attribute EventHandler ontransitionend;
  attribute EventHandler ontransitioncancel;
};