“咏叹调所描述的”是什么意思?财产?
以下 HTML 是由 jQuery Grid 插件插入的:
<td role="gridcell" style="" aria-describedby="list_createdBy">Sam</td>
'aria-descriptedby' 属性的含义是什么?
The following HTML is inserted by the jQuery Grid plugin:
<td role="gridcell" style="" aria-describedby="list_createdBy">Sam</td>
What is the meaning of the 'aria-describedby' property?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
aria 规范对此进行了描述。它给出了元素的 id,该元素提供了一些用户可能需要的有关当前元素的一些附加信息。
This is described in the aria specification. It gives the id of an element that provides some additional information about the current element that some users might need.
下面是如何使用 aria-descriptedby 属性的示例。当您的文本包含有关元素的信息时,将使用它。 Aria-descriptedby 必须与描述它的文本的 id 相同。
名字:
您的名字必须正确。
Here below is an example of how you could use the aria-describedby property. It is used when you have a text that has information about the element. Aria-describedby must be the same as the id of the text that describes it.
First name: <input aria-describedby="name" type="text">
<em id="name">Your first name must be correct.</em>
乍一看,我会说
aria-scribedby
在这里可能会被忽略,因为它是在上定义的。当设置在不可交互(可聚焦)的元素上时,大多数浏览器和屏幕阅读器将忽略 aria-scribedby 信息。
但具体示例有点复杂,因为
role="gridcell"
覆盖了的语义,因此如果提供的示例遵循 < a href="https://www.w3.org/TR/wai-aria-1.1/#gridcell" rel="noreferrer">gridcell 的 ARIA 规范。这是一个自定义组件。
一般来说,属性
aria-descriptedby
为屏幕阅读器提供了要在元素内容中公布的附加信息(不是唯一的,而是最常见的用例) 。例如,屏幕阅读器将宣布
“Logout,John Doe”,而不是仅
“Logout”
:或者带有工具提示的示例(提示:此处缺少Javascript部分):
或者带有表单元素的示例,另一个常见用例:
上面的示例将在用户聚焦输入字段。它不仅不需要读取周围环境来理解预期输入的内容,而且在
关于 ARIA:
aria-hidden
或aria-expanded
。但前提是正确实施和测试!关于 aria-scribedby
a
或button
上实现,如果引用的元素被隐藏(display:none
),它的位置(是引用的内部元素?)或者它是否有tabindex="-1"
或role
(例如role="none"
)等。确保测试所有屏幕阅读器aria-scribedby
仅在对焦模式下。因此,将其添加到不可聚焦的元素中是没有意义的。来自:ADGCtrl+F
进行搜索(这是用户浏览网站以快速找到所需内容的常用方式)。来自:ADGaria-descriptedby
的用法是将附加信息附加到交互元素(例如,将可见信息与表单控件相关)。来自: ADGrole="alert"
(在 SPAN 上)用于表单控件错误。来自:W3.orgAt the first glance I'd say
aria-describedby
is likely to be ignored here because it's defined on<td>
. Most browsers and screen readers will ignorearia-describedby
information when set on element which is not interactive (focusable).But the specific example a bit more complex due to
role="gridcell"
which overrides the semantics of<td>
and therefore the provided example is valid if it follows the ARIA specification for gridcell. It's a custom component.Generally speaking the attribute
aria-describedby
provides the screen reader with the additional information to be announced along the content of the element (not the only but the most common use-case).For example instead of only
"Logout"
the screen reader will announce"Logout, John Doe"
:Or example with a tooltip (Hint: Javascript part is missing here):
Or example with a form element, another common use-case:
The example above will announce both
<label>
and the additional description (defined byaria-describedby
) immediately when a user focuses the input field. Not only that it eliminates a need to read the surroundings to be able to understand what is expected to enter but also reading all elements other than form controls when inside of the<form>
might be more complex for a screen reader user. It's a different experience then reading the rest of the page. Because keyboard events can either interact with screen readers or with form controls, but hardly with both in the same time. Not to mention that screen readers offer bunch of useful keyboard shortcuts for example pressing "H" will jump to a next heading but obviously not when<input>
field is focused. Then "H" will be entered into<input>
.About ARIA:
aria-hidden
oraria-expanded
. But only if implemented and tested properly!About aria-describedby
a
orbutton
as well if referenced element is hidden (display:none
), its position (is the inner element referenced?) or if it hastabindex="-1"
orrole
(e.g.role="none"
) on it etc. Make sure to test all screen readersaria-describedby
only in focus mode. As such, it does not make sense to add it to non-focusable elements. From: ADGCtrl+F
(which is a common way the users like to navigate the website to quickly find what they look for). From: ADGaria-describedby
, is to attach additional information to interactive elements (e.g. to relate visible information e.g. to form controls). From: ADGaria-describedby
(on a form control) androle="alert"
(on a SPAN) for a form control error. From: W3.org基本上,
aria-scribedby 属性用于通过使用 id 引用列表将描述性信息附加到一个或多个 HTML 标记(id 引用列表包含一个或多个唯一的 HTML 标记 id< /em>)。
aria-scribedby 属性与 aria-labelledby 属性非常相似(描述 HTML 标记本质的标签),但是 aria -descriptedby 属性提供有关用户可能需要的 HTML 标记的更多信息。
属性 aria-scribedby 和 aria-labelledby 主要对使用屏幕阅读器等辅助技术的用户有用>。
供参考:
https:// developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-scribedby_attribute
https://www.w3.org/TR/WCAG20-TECHS/ARIA1.html
Basically,
aria-describedby property is used to attach descriptive information to one or more HTML tags through the use of an id reference list( an id reference list contains one or more unique HTML tag ids).
aria-describedby property is very similar to aria-labelledby property( a label which describes the essence of a HTML tag) but aria-describedby property provides more information about a HTML tag that user might need.
The properties aria-describedby and aria-labelledby are mainly useful to the users who use assistive technologies like a screen reader.
For reference:
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute
https://www.w3.org/TR/WCAG20-TECHS/ARIA1.html