The short answer

#

Wrap movement-heavy animations in a prefers-reduced-motion media query. The safest pattern is "motion is opt-in": only add the animation when the person has no preference, so everyone else gets a calm version by default.


_11
.card {
_11
opacity: 0;
_11
transition: opacity 200ms ease;
_11
}
_11
_11
@media (prefers-reduced-motion: no-preference) {
_11
.card {
_11
transform: translateY(1rem);
_11
transition: opacity 200ms ease, transform 400ms ease;
_11
}
_11
}

Why it happens

#

Large or fast movement on screen, such as parallax, zooming, sliding panels and auto-playing carousels, can trigger dizziness, nausea or headaches for people with vestibular disorders, and can distract people with attention or cognitive differences. Every major operating system has a setting to reduce motion. On macOS and iOS it is in the Accessibility settings, on Windows it is "Animation effects", and Android has "Remove animations".

Browsers expose that setting to CSS through the prefers-reduced-motion media feature. It has two values:

  • no-preference: the person has not asked for less motion.
  • reduce: the person has asked for less motion.

Your CSS does not respect this automatically. Animations and transitions run for everyone unless you write rules for it.

How to fix it

#

Make motion opt-in

Write the static or gentle version first, then add movement inside the no-preference query.


_17
.toast {
_17
animation: fade-in 200ms ease-out;
_17
}
_17
_17
@media (prefers-reduced-motion: no-preference) {
_17
.toast {
_17
animation: slide-in 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
_17
}
_17
}
_17
_17
@keyframes fade-in {
_17
from { opacity: 0; }
_17
}
_17
_17
@keyframes slide-in {
_17
from { opacity: 0; transform: translateX(100%); }
_17
}

This approach is safer than the reverse, because a new animation added later without a media query is the gentle one.

Reduce rather than remove

Reduced motion does not mean no change at all. Fades, colour changes and short opacity transitions rarely cause problems and still tell people something happened. Replace movement with a cross-fade instead of making things snap.


_10
@media (prefers-reduced-motion: reduce) {
_10
.modal {
_10
animation-name: fade-in;
_10
}
_10
}

Add a global safety net

On an existing site with many animations, a global rule in the reduce query is a quick improvement while you go through them one by one.


_10
@media (prefers-reduced-motion: reduce) {
_10
*,
_10
*::before,
_10
*::after {
_10
animation-duration: 0.01ms !important;
_10
animation-iteration-count: 1 !important;
_10
transition-duration: 0.01ms !important;
_10
scroll-behavior: auto !important;
_10
}
_10
}

A tiny duration is used instead of none so that animationend and transitionend events still fire, which some JavaScript relies on. This is a blunt tool, so treat it as a fallback, not the whole fix.

Check the preference in JavaScript

Animation libraries, canvas effects and auto-playing video are not controlled by CSS. Read the same setting with matchMedia and listen for changes.


_10
const query = window.matchMedia("(prefers-reduced-motion: reduce)");
_10
_10
function applyMotionPreference() {
_10
document.documentElement.dataset.motion = query.matches ? "reduce" : "full";
_10
}
_10
_10
applyMotionPreference();
_10
query.addEventListener("change", applyMotionPreference);

Test it

You can switch the setting without changing your system. In Chrome and Edge DevTools, open the Rendering panel and emulate prefers-reduced-motion: reduce. Firefox and Safari also offer ways to emulate it, or you can turn on the operating system setting.

Common pitfalls

#
  • Removing all feedback. Turning off every transition can make interfaces feel broken. Keep fades and colour changes.
  • Forgetting smooth scrolling. scroll-behavior: smooth is motion too. Put it inside the no-preference query.
  • Auto-playing media. Background videos and animated images keep moving whatever your CSS says. Pause them, or show a still image, when motion is reduced, and give everyone a pause control.
  • Only handling CSS. JavaScript-driven animations need their own check.
  • Treating it as optional polish. WCAG 2.2 includes success criteria about motion, such as pausing moving content and motion triggered by interaction. Respecting this setting is one of the simplest ways to meet them.
#
file under:
CSS

quick question

Was this resource helpful?