Web development
Respect a reduced-motion preference
Use prefers-reduced-motion to reduce nonessential motion for people who request it. Apply the change to the actual moving components instead of assuming a single global rule covers every interaction.
Worked example
HTML example · save as example.html and open in a browser
<style>
.card{transition:transform .2s ease}
.card:hover{transform:translateY(-4px)}
@media(prefers-reduced-motion:reduce){
.card{transition:none}
.card:hover{transform:none}
html{scroll-behavior:auto}
}
</style>
<p class="card">A card with an optional hover movement.</p>How it works
The media query reflects the user’s preference. The example removes the card movement itself, not only its transition, and avoids smooth scrolling. Content and controls remain available regardless of whether motion is enabled.
Limits and mistakes
Do not remove a necessary status indication without providing another understandable cue. JavaScript animations and canvas rendering need corresponding logic if they do not follow CSS. Test the full interaction with the preference enabled.
Check the result
Emulate reduced motion in developer tools or change the operating-system setting. Hover the card and confirm it no longer moves while its content remains readable.
Sources
Reference documentation for the behavior used in this guide: