Use prefers-reduced-motion CSS Media Query to Improve Web Accessibility in your App

Will Mendes
InstructorWill Mendes
Share this video with your friends

Social Share Links

Send Tweet
Published 3 years ago
Updated 3 years ago

CSS Media queries are heavily used across web pages for different reasons, such as make your web pages responsive, but what if we can use them to improve web accessibility as well? In this case, you can use prefers-reduced-motion CSS media query to improve web accessibility in your web app by adding this support, respecting the user’s OS option Reduce Motion for people with disabilities.

Will Mendes: [0:00] Let's write a CSS media query to remove the animation. For that, we will use @media and passing prefers-reduced-motion with the value as reduce.

[0:12] Now, we can define these styles to be applied when the CSS media query is enabled. First, we can create the skeleton-loader, and we can add background-image as none. Also, we can add animation as none. With that, as soon as we add a media query with prefers-reduced-motion as reduce enabled, we have this piece of CSS activated and applied in your page.

[0:42] To check the CSS media query in action, you can open accessibility tools and click in Reduce motion. You can enable and disable. When you enable, the animation should not work. When you disable, it'll be back, as expected.

egghead
egghead
~ 26 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today