aria-label、aria-labelledby 和 aria-describedby:屏幕阅读器中非常不可预见的行为 [英] aria-label, aria-labelledby and aria-describedby: very unforeseeable behaviour in screenreaders

查看:69
本文介绍了aria-label、aria-labelledby 和 aria-describedby:屏幕阅读器中非常不可预见的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚注意到,虽然 aria-labelaria-labelledbyaria-描述的 属性据说适用于每个元素(见 https://www.w3.org/WAI/PF/aria-1.1/states_and_properties#aria-scribedby),它们似乎只适用于像 a 这样的几个元素,而不适用于例如NVDA 和 JAWS 中的 divp.

I just noticed that although the aria-label, aria-labelledby and aria-describedby attributes are said to work on every element (see https://www.w3.org/WAI/PF/aria-1.1/states_and_properties#aria-describedby), they only seem to work for a few elements like a, and not for e.g. div or p in NVDA and JAWS.

我创建了一个小代码笔来演示这个问题(使用浏览和焦点模式浏览它):

I have created a small codepen to demonstrate the issue (browse it using browse and focus mode):

https://codepen.io/jmuheim/pen/avWbPe

例如,在 NVDA 中,在 a 元素上,aria-labelaria-labelledby 似乎在浏览和对焦模式.但是 aria-描述的 只在焦点模式下公布,在浏览模式下不公布.

For example, in NVDA, on the a element, the aria-label and aria-labelledby seem to work in both browse and focus mode. But aria-describedby is only announced in focus mode, not in browse mode.

对于 input 元素,似乎没有一个属性在浏览模式下工作,但所有属性都在焦点模式下工作.

For the input element, none of the attributes seem to work in browse mode, but all work in focus mode.

对于像 pdiv 这样的裸"文本元素,这些属性似乎都不起作用.

For "bare" text elements like p or div, none of the attributes seem to work.

在 JAWS 中,这是非常相似的行为,但至少对于 p 元素,当存在 aria-describedby 时,它宣布可以通过以下方式读取描述按JAWS + alt + r".

In JAWS, it's quite similar behaviour, but at least for the p element, when there is an aria-describedby, it announces that a description can be read by pressing "JAWS + alt + r".

我真的没有看到明确的模式,所以我想知道屏幕阅读器中如何使用这些属性的一般规则是什么?或者更好:为什么它们不像规范建议的那样简单地适用于每个元素?

I don't really see a clear pattern for this, so I wonder what are the general rules in screenreaders on how to use these attributes? Or better: why don't they simply work for every element, as the spec proposes?

推荐答案

ARIA 没有定义辅助技术如何公开 UI.它确实定义了需要浏览器如何通过可访问性公开角色、状态和属性蜜蜂.通常与 HTML 相同,HTML 规范不定义/要求 UI,这由浏览器决定.对于 aria-label(例如),ARIA 要求将 aria-label 映射到 可访问性 API,不要求屏幕阅读器在任何给定元素上宣布或不宣布它(即作为听觉 UI 的一部分公开).一般观察规则是屏幕阅读器将宣布可访问的名称和可访问的描述交互元素.他们将在大多数分组元素分段元素.他们不会在大多数文本级元素.

ARIA does not define how assistive tech are to expose UI. It does define how browsers are required to expose roles, states and properties via accessibility APIs. It's the same with HTML in general, the HTML spec does not define/require UI, that is left up to the browsers to decide. In the case of aria-label (for example) it is a requirement in ARIA that aria-label is mapped to the accessible name property in accessibility APIs, it is not a requirment that screen readers announce it, or not, on any given element (i.e. expose as part of the aural UI). General observed rule is that screen readers will announce accessible names and accessible descriptions on interactive elements. They will announce accessible names on most grouping elements and sectioning elements. They will announce neither on most text level elements.

注意:上述内容也适用于任何默认语义被 ARIA 角色覆盖的元素.例如,ARIA 小部件角色 将同时公布 acc 名称和描述,像原生 HTML 交互元素.

Note: the above also applies to any element that has it's default semantics overidden with ARIA roles. For example ARIA widget roles will have both acc name and description announced, like native HTML interactive elements.

这篇关于aria-label、aria-labelledby 和 aria-describedby:屏幕阅读器中非常不可预见的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆