CSS Animation & Easing Functions
Transitions versus keyframes, what each easing keyword really does (we measured them in Chromium: ease is 80% done at the halfway point), linear() for bounces, why transform beats left (122 layouts versus 1), and reduced motion.
Transitions or Keyframes
CSS has two ways to animate. A transition animates a property from its old value to its new one when something changes it, such as a hover or a class toggle: you declare which property, how long and which easing. A keyframe animation runs a named sequence of stages, can loop, and starts on its own. Use transitions for state changes and keyframes for anything with more than two steps or that should run without a trigger, such as a loading spinner.
.button { transition: transform 200ms ease-out; }
.button:hover { transform: translateY(-2px); }
@keyframes spin { to { transform: rotate(1turn); } }
.spinner { animation: spin 800ms linear infinite; }
What the Easing Keywords Actually Do
Each keyword is a fixed cubic Bézier curve defined in the CSS Easing specification. We solved those curves and, separately, asked Chromium for the value of an opacity animation from 0 to 1 at a quarter, half and three quarters of its duration (October 13, 2026). The two sets of numbers agreed to three decimal places:
| Easing | Done at 25% of the time | at 50% | at 75% |
|---|---|---|---|
linear | 25% | 50% | 75% |
ease (the default) | 40.9% | 80.2% | 96% |
ease-in | 9.3% | 31.5% | 62.2% |
ease-out | 37.8% | 68.5% | 90.7% |
ease-in-out | 12.9% | 50% | 87.1% |
The default is not the gentle symmetrical curve it is often described as. ease covers 41% of the distance in the first quarter of the time and 80% by the halfway point, then spends the second half creeping over the last 20%. ease-in-out is the symmetrical one. A common convention is ease-out for elements entering the screen, which start fast and settle, and ease-in for elements leaving.
For anything else, cubic-bezier(x1, y1, x2, y2) takes the two control points directly. The x values must stay between 0 and 1, but the y values may go outside that range, which is how overshoot is made: cubic-bezier(0.34, 1.56, 0.64, 1) passes the end value and settles back. The Easing Wizard lets you drag the control points and see the curve.
linear() for Bounces and Springs
A cubic Bézier cannot bounce more than once. The newer linear() function draws the curve from as many points as you like, joined by straight segments, so it can approximate springs and bounces:
.drop-in {
animation: drop 600ms linear(0, 0.6 30%, 1.08 55%, 0.97 75%, 1.01 88%, 1) both;
}
Each entry is an output value, optionally with the point in time it belongs to. MDN's compatibility data lists linear() in Chrome and Edge 113, Firefox 112 and Safari 17.2, so it works in every current major browser; older browsers ignore the whole declaration, so put a cubic-bezier() version before it as a fallback.
Which Properties Are Cheap to Animate
Animating a property that affects layout makes the browser recompute positions on every frame. We moved the same box 300 px back and forth for two seconds in Chromium, once with left and once with transform: translateX(), and counted the work with the DevTools protocol:
| Animated property | Layouts | Style recalculations |
|---|---|---|
left | 122 | 123 |
transform | 1 | 6 |
With left the browser ran a layout on nearly every frame; with transform it laid the page out once and let the compositor move the box. That is the real reason transform and opacity are the safe choices: they can skip layout and paint. It is not a promise of "GPU at 60 fps": the frame rate follows the display (60, 120 or more frames per second), and paint-heavy properties such as box-shadow stay expensive, as our glow effect guide measured.
Respecting Reduced Motion
Some people get dizzy or nauseous from motion on screen, and every major operating system has a setting to reduce it. Browsers expose that setting as the prefers-reduced-motion media query. Write decorative motion so it only runs when the user has not asked for less:
@media (prefers-reduced-motion: no-preference) {
.card { animation: rise 400ms ease-out both; }
}
WCAG 2.2 success criterion 2.3.3 (level AAA) asks that motion triggered by interaction can be turned off unless it is essential. Reducing motion does not have to mean removing feedback: a fade in place of a slide keeps the state change visible. The CSS Animation Generator and CSS Transition Playground let you try timings before you write them.
- [1]W3C, CSS Easing Functions Level 1 (keyword curves, cubic-bezier) ↗
- [2]CSS Working Group, CSS Easing Functions editor's draft (linear() function) ↗
- [3]MDN browser-compat-data, css.types.easing-function.linear-function, checked Oct 13, 2026 ↗
- [4]MDN, prefers-reduced-motion media feature ↗
- [5]W3C, Understanding WCAG 2.2 SC 2.3.3 Animation from Interactions ↗
- [6]W3C, Web Animations (Element.animate, used for the measurements) ↗