Why reduced motion matters
Animations can be quite distracting to people that suffer from vertigo, have ADHD, or just have a high sensitivity to motion. For some users, excessive motion and animations can cause:- Vertigo and dizziness - Spinning or parallax effects can trigger vestibular disorders
- Nausea - Rapid movements or transitions may cause physical discomfort
- Distraction - Constant motion makes it difficult to focus on content (particularly for users with ADHD)
- Cognitive overload - Too many moving elements can overwhelm users with processing difficulties
- Seizures - In extreme cases, certain animations can trigger seizures
The prefers-reduced-motion media query
A good way to make sure we are not distracting our users is to respect their reduced motion preferences. Modern operating systems allow users to indicate their motion preferences in their system settings. We can detect this preference using the CSSprefers-reduced-motion media query.
How it works
Browser support
The
prefers-reduced-motion media query is supported in all modern browsers including Chrome, Firefox, Safari, and Edge.Implementing reduced motion in CSS
There are several approaches to implementing reduced motion support in your stylesheets.Approach 1: Disable animations selectively
Disable animations on specific elements that could be problematic:Approach 2: Global animation reset
Disable all animations and transitions globally:Approach 3: Reduce instead of remove
For some animations, completely removing them might reduce usability. Instead, consider reducing their intensity:Real-world example from the course
The Web A11y for Devs course demonstrates reduced motion support on button elements:Best practices for animations
Always respect user preferences
Always respect user preferences
Implement
prefers-reduced-motion for all significant animations. This is not optional - it’s an accessibility requirement.Consider subtle alternatives
Consider subtle alternatives
Instead of removing all feedback, replace heavy animations with simpler alternatives like opacity changes or subtle color transitions.
Avoid infinite animations
Avoid infinite animations
Continuous spinning, bouncing, or flashing elements are particularly problematic. If you must use them, ensure they can be paused or disabled.
Test with real users
Test with real users
Enable reduced motion in your system settings and test your site. Does it still feel responsive and provide adequate feedback?
Keep essential animations
Keep essential animations
Some animations improve usability, like smooth scrolling to error messages or highlighting newly added items. You may keep these but reduce their duration or intensity.
Use CSS instead of JavaScript when possible
Use CSS instead of JavaScript when possible
CSS animations are easier to control with media queries and typically perform better.
Enabling reduced motion in your OS
To test your implementations, enable reduced motion in your system settings:- Windows
- macOS
- iOS
- Android
- Open Settings
- Go to Accessibility > Visual effects
- Toggle off “Animation effects”
JavaScript detection
You can also detect motion preferences in JavaScript:Listening for changes
Users can change their preferences while your site is open:Exercise: Implement reduced motion
Practice exercise
In the Web A11y for Devs course, there’s a spinner that continuously rotates. Your task is to disable this animation when users have reduced motion preferences enabled.File: Hint: Use the
src/exercises/reduced-motion/reduced-motion.cssTask: Add CSS to stop the spinner animation when prefers-reduced-motion: reduce is true.The spinner HTML:@media (prefers-reduced-motion: reduce) query to target the spinner and set animation: none.Common mistakes to avoid
- Removing all transitions - Some transitions aid usability (like smooth state changes)
- Breaking functionality - Ensure interactive elements still work without animations
- Ignoring parallax effects - These are particularly problematic and should always be disabled
- Forgetting scroll behavior - Also set
scroll-behavior: autoin your reduced motion styles - Not testing - Always test with reduced motion enabled in your system