Working Draft · css-transitions

CSS Transitions

6 properties, 1 at-rule defined by this specification, all known to at least one browser .

Each feature in detail

transition

Property Baseline: widely availablesince March 2018 Modern CSS: transition-behavior

MDN The transition CSS shorthand property for transition-property, transition-duration, transition-timing-function, transition-delay, and transition-behavior.

Live preview Example from MDN
#example-element {
  background-color: #e4f0f5;
  color: black;
  padding: 1rem;
  border-radius: 0.5rem;
  font: 1em monospace;
  width: 100%;
  transition: margin-right 2s;
}

#default-example:hover > #example-element {
  background-color: #990099;
  color: white;
  margin-right: 40%;
}

Syntax

<single-transition>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
see individual properties
Applies to
all elements
Inherited
no
Percentages
N/A
Computed value
see individual properties
Canonical order
per grammar
Animation type
not animatable
Longhands
transition-property, transition-duration, transition-timing-function, transition-delay, transition-behavior

Browser support

First browser version supporting transition
Chrome 26
Edge 12
Firefox 16
Safari 9
Chrome Android 26
Safari iOS 9

First version with support, from MDN browser-compat-data.

transition-behavior

Property Baseline: newly availablesince August 2024 Modern CSS: display animationModern CSS: transition-behavior

MDN The transition-behavior CSS property specifies whether transitions will be started for properties whose animation behavior is discrete.

Live preview Example from MDN
html {
  font-family: "Helvetica", "Arial", sans-serif;
}

[popover] {
  font-size: 1.2rem;
  padding: 10px;
}

[popover]:popover-open {
  opacity: 1;
  transform: scaleX(1);
}

[popover] {
  /* Final state of the exit animation */
  opacity: 0;
  transform: scaleX(0);

  transition-property: opacity, transform, overlay, display;
  transition-duration: 0.7s;
  transition-behavior: allow-discrete;
  /* Using the shorthand transition property, we could write:
    transition: 
      opacity 0.7s,
      transform 0.7s,
      overlay 0.7s allow-discrete,
      display 0.7s allow-discrete;

    or even:
    transition: all 0.7s allow-discrete;
  */
}

/* Needs to be included after the previous [popover]:popover-open 
   rule to take effect, as the specificity is the same */
@starting-style {
  [popover]:popover-open {
    opacity: 0;
    transform: scaleX(0);
  }
}

Syntax

<transition-behavior-value>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
normal
Applies to
All elements
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
not animatable

Browser support

First browser version supporting transition-behavior
Chrome 117
Edge 117
Firefox 129
Safari 17.4
Chrome Android 117
Safari iOS 17.4

First version with support, from MDN browser-compat-data.

transition-delay

Property Baseline: widely availablesince March 2018

MDN The transition-delay CSS property specifies the duration to wait before starting a property's transition effect when its value changes.

Live preview Example from MDN
#example-element {
  background-color: #e4f0f5;
  color: black;
  padding: 1rem;
  border-radius: 0.5rem;
  font: 1em monospace;
  width: 100%;
  transition: margin-right 2s;
}

#default-example:hover > #example-element {
  background-color: #990099;
  color: white;
  margin-right: 40%;
}

Syntax

<time>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

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

Browser support

First browser version supporting transition-delay
Chrome 26
Edge 12
Firefox 16
Safari 9
Chrome Android 26
Safari iOS 9

First version with support, from MDN browser-compat-data.

transition-duration

Property Baseline: widely availablesince March 2018

MDN The transition-duration CSS property sets the length of time a transition animation should take to complete. By default, the value is 0s, meaning that no animation will occur.

Live preview Example from MDN
#example-element {
  background-color: #e4f0f5;
  color: black;
  padding: 1rem;
  border-radius: 0.5rem;
  font: 1em monospace;
  width: 100%;
  transition: margin-right 2s;
}

#default-example:hover > #example-element {
  background-color: #990099;
  color: white;
  margin-right: 40%;
}

Syntax

<time [0s,∞]>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

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

Browser support

First browser version supporting transition-duration
Chrome 26
Edge 12
Firefox 16
Safari 9
Chrome Android 26
Safari iOS 9

First version with support, from MDN browser-compat-data.

transition-property

Property Baseline: widely availablesince March 2018

MDN The transition-property CSS property sets the CSS properties to which a transition effect should be applied.

Live preview Example from MDN
#example-element {
  background-color: #e4f0f5;
  color: black;
  padding: 1rem;
  border-radius: 0.5rem;
  font: 1em monospace;
  width: 100%;
  transition: margin-right 2s;
}

#default-example:hover > #example-element {
  background-color: #990099;
  color: white;
  margin-right: 40%;
}

Syntax

none | <single-transition-property>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

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

Browser support

First browser version supporting transition-property
Chrome 26
Edge 12
Firefox 16
Safari 9
Chrome Android 26
Safari iOS 9

First version with support, from MDN browser-compat-data.

transition-timing-function

Property Baseline: widely availablesince March 2018

MDN The transition-timing-function CSS property sets how intermediate values are calculated for CSS properties being affected by a transition effect.

Live preview Example from MDN
#example-element {
  background-color: #e4f0f5;
  color: black;
  padding: 1rem;
  border-radius: 0.5rem;
  font: 1em monospace;
  width: 100%;
  transition: margin-right 2s;
}

#default-example:hover > #example-element {
  background-color: #990099;
  color: white;
  margin-right: 40%;
}

Syntax

<easing-function>#

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
ease
Applies to
all elements
Inherited
no
Percentages
N/A
Computed value
as specified
Canonical order
per grammar
Animation type
not animatable

Browser support

First browser version supporting transition-timing-function
Chrome 26
Edge 12
Firefox 16
Safari 9
Chrome Android 26
Safari iOS 9

First version with support, from MDN browser-compat-data.

@starting-style

At-rule Baseline: newly availablesince August 2024 Modern CSS: @starting-style

Spec The @starting-style rule is a grouping rule. The style rules inside it are used to establish styles to transition from, if the previous style change event did not establish a before-change style for the element whose styles are being computed.

MDN The @starting-style CSS at-rule is used to define starting values for properties set on an element that you want to transition from when the element receives its first style update, i.e., when an element is first displayed on a previously loaded page.

Live preview Example from MDN
div {
  width: 200px;
  height: 100px;
  border: 1px solid black;
  margin-top: 10px;
}

div::after {
  content: "class: " attr(class);
  position: relative;
  top: 3px;
  left: 3px;
}

div {
  background-color: yellow;
  transition: background-color 3s;
}

div.showing {
  background-color: skyblue;
}

@starting-style {
  div.showing {
    background-color: red;
  }
}

Browser support

First browser version supporting @starting-style
Chrome 117
Edge 117
Firefox 129
Safari 17.5
Chrome Android 117
Safari iOS 17.5

First version with support, from MDN browser-compat-data.