How to make NVDA screen reader read the aria-label?

旧城冷巷雨未停 提交于 2019-12-13 05:43:31

问题


Screen reader not reading this div:

<div tabindex="7" aria-label="Here be redundant or extraneous content" >

It should read "Here be redundant or extraneous content"

Any help how to solve this problem with HTML?


回答1:


A div is neither landmark nor interactive content. An aria-label will not be read by a screen reader (and rightly so).

Use an off-screen technique:

<div class="sr-only">
Here be redundant or extraneous content
</div>

The CSS might look like this (accounting for RTL languages too):

.SRonly {
  position: absolute !important;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
  top: auto;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

html[dir=rtl] .SRonly {
  left: inherit;
  left: unset;
  right: -9999px;
}

There are other techniques, but their value depends on your audience and its technology profile.

Further, never use a positive tabindex value. And never use a div as interactive content (which the tab-stop implies is your intent).

In the future, your question might get more attention if you provide an example and description of the challenge you are trying to solve.



来源:https://stackoverflow.com/questions/40423511/how-to-make-nvda-screen-reader-read-the-aria-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!