Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I adjust my animations to respect the prefers-reduced-motion setting for better accessibility?
Asked on Jan 05, 2026
Answer
To respect the prefers-reduced-motion setting, you can use a media query to detect if the user has requested reduced motion and adjust your animations accordingly. This ensures your website is more accessible to users who may experience discomfort with motion effects.
<!-- BEGIN COPY / PASTE -->
@keyframes exampleAnimation {
from { opacity: 0; }
to { opacity: 1; }
}
.animated-element {
animation: exampleAnimation 2s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
.animated-element {
animation: none;
}
}
<!-- END COPY / PASTE -->Additional Comment:
- The prefers-reduced-motion media query allows you to detect user preferences for reduced motion.
- In the example, the animation is disabled by setting "animation: none" when reduced motion is preferred.
- This approach enhances accessibility by respecting user settings, reducing potential motion-triggered discomfort.
- Consider applying this technique to all animations and transitions on your site for comprehensive accessibility support.
Recommended Links:
