---
title: "How do I respect prefers-reduced-motion in CSS?"
description: "Use the prefers-reduced-motion media query to tone down or remove animations for people who ask their system for less motion, without removing useful feedback."
url: https://www.danny.engineering/answer/css/how-do-i-respect-prefers-reduced-motion-in-css
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T20:30:00.000Z
tags: ["CSS"]
---

# How do I respect prefers-reduced-motion in CSS?

## 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.


```css
.card {
  opacity: 0;
  transition: opacity 200ms ease;
}

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


## 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.


```css
.toast {
  animation: fade-in 200ms ease-out;
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: slide-in 400ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(100%); }
}
```


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.


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


### 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.


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


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.


```javascript
const query = window.matchMedia("(prefers-reduced-motion: reduce)");

function applyMotionPreference() {
  document.documentElement.dataset.motion = query.matches ? "reduce" : "full";
}

applyMotionPreference();
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.

## Related reading

- [MDN: prefers-reduced-motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion)
