{"canonical_url":"https://engineer.company/glossary/animation/","content_markdown":"# Animation\n\n## What it is\n\nOn the web, an animation is most often a CSS animation: a named run of\nkeyframes, written once in an `@keyframes` rule and attached to an element\nthrough the `animation` properties. The W3C's CSS Animations Level 1\nspecification describes the mechanism as a way “to animate the values of CSS\nproperties over time, using keyframes”. Animated images, video and canvas\ndrawing move too; this article follows the declarative kind.\n\nEach keyframe states property values at a point in the run: `from` or `0%` at\nthe start, `to` or `100%` at the end, and any percentages in between. The\nbrowser fills in the values between them. The other animation properties set how\nlong one run lasts, how many times it repeats, whether alternate runs play in\nreverse and whether it is running or paused. A repeat count of `infinite` means,\nin the specification's words, that the animation “will repeat forever”.\n`animation-fill-mode` decides what shows outside the run: with `none` the\nanimation has no effect then, `backwards` applies the first keyframe during any\ndelay, and `forwards` keeps the values it ended on.\n\nA transition is the near relation: where a changed property value would normally\nshow at once, CSS Transitions spreads the change over a set duration. CSS\nAnimations draws the line between the two: transitions trigger implicitly when a\nproperty value changes, while animations “are explicitly executed when the\nanimation properties are applied”. A link that fades its colour on hover is a\ntransition; a loading spinner that turns whether or not anything changed is an\nanimation.\n\nA newer specification, Scroll-driven Animations, swaps the clock for the page\nitself. An animation attached to a scroll progress timeline advances as a\nscroll container scrolls, from 0% at the start of the scrollable range to 100%\nat its end. When those two positions coincide, because there is nothing to\nscroll, the specification calls the timeline inactive.\n\n## Why it matters\n\nMovement pulls attention, which is both the reason to use it and the trouble\nwith it.\n\n**For some readers it is physically unpleasant.** The Understanding document for\nWCAG 2.2 success criterion 2.3.3 explains that elements moving as a page scrolls\ncan trigger reactions in people with vestibular, or inner-ear, disorders:\ndizziness, nausea and headaches. It names parallax scrolling, where backgrounds\nmove at a different rate from the foreground, as an animation that is often\nnon-essential, and notes that the impact can be severe enough to need bed rest\nto recover.\n\n**Readers can say so, and a page can ask.** Media Queries Level 5 defines\n`prefers-reduced-motion`, a media feature with two values. `reduce` means the\nreader has told the system they prefer an interface that “removes or replaces\nthe types of motion-based animation” that cause discomfort for people with\nvestibular motion sensitivity or distraction for people with attention\ndeficits. `no-preference` means no preference is known, and it evaluates as\nfalse when the feature is tested on its own.\n\n**Two success criteria cover it.** 2.2.2 Pause, Stop, Hide, at level A, applies\nto moving, blinking or scrolling content that starts automatically, lasts more\nthan five seconds and is shown alongside other content: the reader must be able\nto pause it, stop it or hide it, except where the movement is essential. It\napplies to everything on the page, and an animation that stops only while focus\nrests on it does not count as a pause. 2.3.3 Animation from Interactions, at\nlevel AAA, asks that motion animation triggered by an interaction can be\ndisabled, unless it is essential. Its Understanding document lists the\nreduce-motion feature of the browser or operating system as one way to meet it.\n\n**Not every change is motion.** WCAG defines motion animation as the “addition\nof steps between conditions to create the illusion of movement or to give a\nsense of a smooth transition”. An element that moves into position or changes\nits size as it appears counts as animated; one that appears instantly is not. A\nchange of colour or opacity that leaves the element's perceived size, shape and\nposition alone falls outside the definition, which is why reducing motion does\nnot mean freezing every fade.\n\n## What it looks like in practice\n\nThe plainest lesson starts with a rule that looked finished. The site honoured\nthe reduce-motion preference with a single universal rule switching every\ntransition off; it read as complete and passed its linter, yet under an emulated\npreference eleven selectors were still animating. The work that\n[made the reduced-motion setting honest](/portfolio/made-the-reduced-motion-setting-honest/)\ntraced the cause to specificity: a universal selector loses to any rule that\ncarries a class, which is every considered animation on the page. Everything\nthat moves now lives in one late stylesheet part, and a linter fails a\ntransitioned transform anywhere else. The line it draws is reduce motion, not\ncolour, so a colour fade passes and a transition on movement does not. Motion is\nalso expressed as a transition rather than a keyframe animation, because the\nfirst is trivially cancellable and the second is not. As the page puts it, a\nrule that loses on specificity fails silently.\n\nScroll-driven motion has a failure of its own. Among the\n[11 accessibility defects the browser reported as healthy](/portfolio/the-accessibility-faults-your-checker-misses/)\nwas a scroll-driven animation, inactive on a page too short to scroll, that had\npermanently clipped the footer off three pages. The automated rules had passed\nit, because the defect lay in how the page rendered, not in its markup.\n\nA linter can make the check impossible to skip. A\n[48-token design system](/portfolio/built-a-48-token-macos-design-system/), built\non the platform's own glass material, keeps motion as one of its six token\ngroups, and its linter rejects an animation declared without honouring the\nreduce-motion preference. The page gives the reason: an animation is added in a\nmoment of polish, the preference check is the part that gets skipped, and so\nthe rule makes the animation impossible to write without it.\n\nThis site's stylesheets show the same habits elsewhere. The two gears in the\nmasthead turn on 60-second and 96-second loops, and both are set to `animation:\nnone` under `reduce`. Their scroll-linked parallax is gated twice, inside\n`prefers-reduced-motion: no-preference` and inside an `@supports` test for\n`animation-timeline: scroll()`; in a browser without the feature the gears stay\nwhere they are, and the comment calls that fallback the design. In the footer,\nthe credit block that holds the copyright takes its hidden state from the\nanimation's backwards fill rather than from a declared `opacity: 0`. The comment\ngives the reason: an inactive timeline applies no effect at all, and the old\n`opacity: 0` had hidden the copyright on every short page.\n\n## Where it goes wrong\n\n- **The off switch loses the cascade.** A blanket `transition: none` on the\n  universal selector has almost no specificity, so any rule with a class keeps\n  moving and nothing reports it. A block placed after the rules it has to\n  beat, naming the moving selectors, makes the still state win.\n- **The preference is added later, or never.** An animation in the base style\n  moves for everyone until somebody remembers the cancel. Declaring it inside\n  `@media (prefers-reduced-motion: no-preference)` makes stillness the default.\n- **A scroll timeline meets a page with nothing to scroll.** The timeline is\n  inactive and the animation does nothing, so a starting state written into the\n  base style, such as an `opacity: 0` waiting to be animated away, stays in\n  force. A starting state supplied by the backwards fill goes with the\n  animation.\n- **A keyframe value the browser rejects drops out quietly.** The specification\n  says that a property specified but invalid in a keyframe is animated as if\n  that keyframe did not exist. A misspelt value skips a step without an error.\n- **A decorative loop runs with no way to stop it.** An `infinite` animation\n  that starts on load beside the text falls under 2.2.2 once it passes five\n  seconds; a pause control, or an end within five seconds, answers it.\n- **“Reduce” is read as “remove everything”.** Cutting every state change can\n  take information away with the movement. Showing the new state instantly, or\n  with a fade, keeps the information and drops the motion.\n\n## Further reading\n\n- [CSS Animations Level 1](https://www.w3.org/TR/css-animations-1/)\n  — the `@keyframes` rule, the animation properties, fill modes and the events\n  an animation fires.\n- [CSS Transitions Level 1](https://www.w3.org/TR/css-transitions-1/)\n  — how a change of property value is spread over a duration instead of being\n  applied at once.\n- [Scroll-driven Animations](https://www.w3.org/TR/scroll-animations-1/)\n  — scroll progress timelines, the `scroll()` notation and the cases in which a\n  timeline is inactive.\n- [Media Queries Level 5: prefers-reduced-motion](https://www.w3.org/TR/mediaqueries-5/#prefers-reduced-motion)\n  — the two values and what a reader who chooses `reduce` is asking for.\n- [Understanding SC 2.2.2: Pause, Stop, Hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html)\n  — the five-second limit, what counts as starting automatically and which\n  pause mechanisms qualify.\n- [Understanding SC 2.3.3: Animation from Interactions](https://www.w3.org/WAI/WCAG22/Understanding/animation-from-interactions.html)\n  — vestibular reactions, parallax, and the reduce-motion preference as one way\n  to meet the criterion.\n\n\u003chttps://engineer.company/glossary/animation/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"Keyframes and transitions, the reduced-motion preference, the two WCAG criteria on movement, and the ways an animation breaks without a word.","formats":{"gemtext":"https://engineer.company/glossary/animation/index.gmi","gopher":"https://engineer.company/glossary/animation/gophermap","html":"https://engineer.company/glossary/animation/","json":"https://engineer.company/glossary/animation/index.json","markdown":"https://engineer.company/glossary/animation/index.md","pdf":"https://engineer.company/glossary/animation/index.pdf"},"kind":"page","language":"en","title":"What is an animation?","url":"https://engineer.company/glossary/animation/","version":1}