描述
term 角色可用于表示一个单词或短语,并可选择性地关联一个 definition 角色。它在语义上等同于 HTML 中的 <dfn> 元素,以及定义列表(<dl>)中的定义术语(<dt>)元素。
term 角色用于明确标识一个单词或短语,该单词或短语已由作者提供定义,或用户期望提供定义。如果已存在定义,或存在用于输入定义的表单或表单控件,作者应设置 aria-details 指向相关元素。
请勿在链接等交互式元素上使用 role="term",因为它会干扰辅助技术用户与元素的交互能力。此外,术语本身就是可访问名称,因此请勿使用 aria-label 或 aria-labelledby。
警告: 可访问名称应该是术语本身,因此请勿使用 aria-label 或 aria-labelledby。
关联的 WAI-ARIA 角色、状态和属性
无。
键盘交互
无。
所需的 JavaScript 功能
无。
示例
html
<p>
<span role="term">Mansplaining</span>,
<span role="definition"
>a portmanteau of "man" and "explain", is the patronizing act of explaining
without being asked to do so, to someone already learned on the topic, often
after someone has already explained it</span
>.
</p>
包含更好的语义,上述内容也可以写成
html
<p>
<dfn role="term">Mansplaining</dfn>,
<span role="definition"
>a portmanteau of "man" and "explain", is the patronizing act of explaining
without being asked to do so, to someone already learned on the topic, often
after someone has already explained it</span
>.
</p>
或者不使用任何 ARIA(但可能不是你想要呈现的方式)
html
<dl>
<dt>Mansplaining</dt>
<dd>
A portmanteau of "man" and "explain", is the patronizing act of explaining
without being asked to do so, to someone already learned on the topic, often
after someone has already explained it.
</dd>
</dl>
可访问性考虑
请勿在链接等交互式元素上使用 role="term",因为它会干扰辅助技术用户与元素的交互能力。
最佳实践
让术语本身来定义可访问名称。请勿使用 aria-label 或 aria-labelledby。
规范
| 规范 |
|---|
| 无障碍富互联网应用程序 (WAI-ARIA) # term |
另见
- ARIA:
definition角色. - HTML
<dfn>元素