简体   繁体   中英

Is it possible to block a screen reader for certain text?

I have some text on screen describing the button next to it. The button also has a aria-label on it with a much more descriptive indication of what it does.

Visually impaired users do not need to read the on-screen text as the aria-label holds the full context of the button's functionality.

Is there a method for indicating that the onscreen text should not be read by screen readers? All it does is add confusion to the visually impaired people viewing my page.

Thanks!!

You can use aria-hidden on the button to achieve this.

<button aria-label="...">
  <span aria-hidden="true">Some text</span>
</button>

From the docs :

Adding aria-hidden="true" to an element removes that element and all of its children from the accessibility tree. This can be used for hiding duplicated content such as such as repeated text to improve the experience for assistive technology users

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM