屏幕读取器在Mac Chrome上正确阅读,但在Windows Chrome上没有读取
我有一个场景,我添加了一个aria-label
向父< div; gt;
,其中包含一些文本。理想情况下,应先叙述给父< div> div; div; div>
的aria-label
应首先叙述,然后再叙述子文本组件。这在MacOS Chrome上与VoiceOver屏幕阅读器完全效果,但是在Windows Chrome上,nvda parent < div>
aria-label
根本没有阅读。
附加代码片段以供参考:
<div aria-label="Parent div accessibility">
<Text> Some Text </Text>
</div>
Macos Chrome上的语音输出与VoiceOver:
Narrator - Parent div accessibility
Narrator - Some Text
Windows Chrome上的语音输出与NVDA:
Narrator - Some Text
I have a scenario where I have added an aria-label
to a parent <div>
which contains some text. Ideally the aria-label
provided to the parent <div>
should be narrated first and then the child Text component. This works completely fine on MacOS Chrome with the VoiceOver screen reader, but on Windows Chrome with NVDA the parent <div>
aria-label
is not at all read.
Attaching a code snippet for reference:
<div aria-label="Parent div accessibility">
<Text> Some Text </Text>
</div>
Speech output on MacOS Chrome with VoiceOver:
Narrator - Parent div accessibility
Narrator - Some Text
Speech output on Windows Chrome with NVDA:
Narrator - Some Text
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
屏幕读取器在非相互作用元素上解释
aria-label
方面都在地图上。根据 David MacDonald的测试在静态元素上读取
aria-label
文本,但是除非静态内容(例如&lt; div&gt;
)具有remo =',否则jaws和nvda不会导航“
,角色=“ search”
,real =“ main”
或real =“ img”
。根据设计,
aria-label
旨在覆盖元素的现有文本,因为它是大多数屏幕读取器将其解释为元素标签的方法。因此,您从配音中获得的行为不一定是标准行为。某些屏幕读取器(例如对话)会忽略&lt; div&gt;
的内部文本,如果您使用aria-label
,因为它可以解释aria-label < /代码>作为该元素的标签,忽略了元素中的任何其他文本。其他屏幕读取器(如Jaws)将读取
。似乎NVDA 2018在静态元素上使用aria-label
文本和&lt; div; div&gt;
的内部文本em>您将角色添加到静态元素之类的角色=“ navigation”aria-label
确实支持,但后来被删除,因为aria-label
辩论尚未达成共识。选项1
失败安全选项将是使用CSS明显隐藏的文本。所有浏览器/屏幕读取器组合都完全支持这一点。
这是示例 webaim :
option
2 > content 属性隐藏了屏幕读取器要说的文本,如 so so 上的类似问题:
我用jaws和nvda测试了他的建议,它宣布了“这本文是隐藏的“文本以及
&lt; div&gt;
的内部文本。但是,正如Quentinc在注释中指出的那样,CSS
content
属性当前不受所有浏览器/屏幕读取器组合的支持。参考:
澄清在没有角色#756
的元素上使用aria-label
woe-aria: - 标签/ledby
Aria-labelledby,aria-label和aria-descred a aria-labelledby会发生什么情况在静态HTML元素上?
webaim:webaim:仅适用于屏幕阅读器用户的隐形
内容 使用CSS隐藏文本。
Screen readers are all over the map with respect to interpretting
aria-label
on non-interactive elements.According to David MacDonald's tests, VoiceOver and TalkBack will read the
aria-label
text on static elements, but JAWS and NVDA will not unless the static content (like a<div>
) has therole="navigation"
,role="search"
,role="main"
, orrole="img"
.By design,
aria-label
is meant to override the existing text of an element because it is what most screen readers will interpret as the element's label. So, the behaviour you're getting from VoiceOver is not necessarily standard behaviour. Some screen readers (like TalkBack) will ignore the inner text of your<div>
if you usearia-label
, because it interprets thearia-label
as the label for that element and ignores any other text within the element. Other screen readers like JAWS will read both thearia-label
text and the inner text of the<div>
if you add a role likerole="navigation"
to your static element. It seems that NVDA 2018 did support usingaria-label
on static elements, but it was later removed because there's yet to be consensus on thearia-label
debate.Option 1
The fail-safe option would be to use text that is visibly hidden by CSS. This is fully supported by all browser/screen reader combinations.
Here is the example suggested by WebAIM:
Option 2
Another option is to use the CSS
content
property to hide the text that you want spoken by the screen reader, as suggested by slugolicious in a similar question on SO:I tested his suggestion with JAWS and NVDA and it announced the "This text is hidden" text as well as the inner text of the
<div>
.However, as QuentinC pointed out in the comments, the CSS
content
property isn't currently supported by all browser/screen reader combinations.For reference:
Clarify use of aria-label on elements with no role #756
Woe-ARIA: The Surprisingly but Ridiculously Complicated World of aria-label/ledby
What happens with aria-labelledby, aria-label and aria-describedby on static HTML elements?
WebAIM: Invisible Content Just for Screen Reader Users
Update
I edited my original answer to include QuentinC's suggestion of using CSS to hide the text.