CSS prefers-reduced-motion Media Query

Reduced motion without JavaScript detection

Respecting a user's reduced motion preference required JavaScript to check window.matchMedia and conditionally skip animations. The prefers-reduced-motion media query lets CSS respond directly to the OS accessibility setting.

Old way JS required
// JS: check OS preference, disable animations manuallyconst mq = window.matchMedia('(prefers-reduced-motion: reduce)');if (mq.matches) {  document.querySelectorAll('.animated').forEach(    el => el.style.animation = 'none'  );}
5 lines
@media (prefers-reduced-motion: reduce)   {  *, *::before, *::after   {    animation-duration: 0.01ms !important;  }}
Widely available Since 2020 96% global usage

This feature is well established and works across many devices and browser versions. It has been available across browsers since 2020.

Safe to use without fallbacks.

74+
63+
10.1+
79+
right ball stops if OS reduced motion is on
Always animates
No OS check
Respects OS
prefers-reduced-motion
@media (prefers-reduced-motion: reduce) — pure CSS, no JS

Accessibility without JavaScript

Users who experience motion sickness or vestibular disorders can set reduced motion in their OS. This media query lets CSS respond directly, with no JavaScript needed.

Instant, no flash of animation

JavaScript runs after page load, so animations can briefly play before being disabled. CSS applies before paint, so reduced-motion users never see the animation at all.

Reduce, not necessarily remove

Use 0.01ms instead of 0 to preserve animation events that JavaScript might listen for. Or slow animations down with a longer duration rather than disabling them entirely.

Old Approach
JS matchMedia check
Runs after paint, animations flash briefly
Modern Approach
prefers-reduced-motion
CSS applies before paint, zero flash
OS Setting
Accessibility
Reflects system-level preference automatically

How it works

Animations and transitions can cause problems for users with vestibular disorders or motion sensitivity. The traditional approach was to check window.matchMedia('(prefers-reduced-motion: reduce)') in JavaScript and remove animation classes. Because JavaScript runs after the page renders, animated elements could briefly play before being stopped.

@media (prefers-reduced-motion: reduce) applies before paint. Styles inside are active immediately when the OS setting is enabled. Setting animation-duration to 0.01ms effectively disables animations while preserving any JavaScript that listens for animationend events. Using 0 skips the event entirely.

ESC