Course contentsShow
← Web Development
Lesson 400 of 2,9827. Responsive DesignFree lesson

prefers-reduced-motion for Accessibility

Respect user motion preferences to reduce or disable animations for accessibility and comfort.

What You'll Learn

You'll learn how to detect and respect a user's system preference to reduce or disable animations, making your website more comfortable and accessible.


Why Motion Preferences Matter

Some users experience discomfort, dizziness, or even nausea from animations and motion effects on websites—a condition called vestibular disorder. Operating systems now let users indicate they prefer reduced motion, and as developers, we should honor that choice.

Think of it like a "quiet car" on a train: some passengers need a calmer environment to travel comfortably. Similarly, some users need a calmer web experience.


The prefers-reduced-motion Media Feature

The prefers-reduced-motion media query detects if a user has enabled reduced motion in their system settings. It has two possible values:

  • no-preference - User hasn't set a preference (default)
  • reduce - User prefers reduced motion

How to Use It

Wrap animations inside a media query that only applies when motion is acceptable:

/* Default: no animation */
.card {
  transition: none;
}

/* Only animate if user hasn't requested reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .card {
    transition: transform 0.3s ease;
  }
  
  .card:hover {
    transform: scale(1.05);
  }
}

Or inversely, disable animations for users who prefer reduced motion:

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

Testing

On macOS, enable "Reduce Motion" in System Preferences → Accessibility. On Windows, use Settings → Ease of Access → Display → Show animations.


Key Takeaway: Always respect prefers-reduced-motion to make your site accessible and comfortable for users sensitive to motion—it's a simple media query that shows you care about inclusive design.