Respect prefers-reduced-motion
Turn off or shorten animations for users who ask their system for less motion.
- CSS
- GreenSnippets
- MIT
@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;
}
}Example / expected output
/* Test it: enable "Reduce motion" in your OS accessibility settings. */How it works
Large movement can cause nausea or distraction for some people, and they signal this through an operating-system setting. The media query below cuts animation and transition durations and disables smooth scrolling for them. Essential animations (such as a progress spinner) can opt out with a more specific rule.
This snippet has been reviewed but was not executed by an automated test. Test it in your own environment before relying on it.
Related snippets
- CSS
Accessible focus ring with :focus-visible
Show a clear focus outline for keyboard users without drawing it on mouse clicks.
- HTML
Accessible modal with the dialog element
Use the native dialog element for a modal with built-in focus trapping, Escape to close and a backdrop.
- HTML
Accordion with details and summary
A keyboard-accessible FAQ accordion with no JavaScript, including an exclusive group using the name attribute.
- CSS
Accessible button styles with states
A base button with hover, active, disabled and focus styles that meets minimum target size.

