html 中的 ARIA "role" 到底有什么用?
What exactly is the use of ARIA "role" in html?
我看到了 ARIA 'role' 的文档,但无法理解。它到底是做什么的?比如说,我像这样在 table 中使用它:
<td role='button'>text</td>
这是否意味着此单元格将充当按钮?有人可以用更简单的术语解释一下吗?
您可以参考 MDN 上面写着:
The button role should be used for clickable elements that trigger a
response when activated by the user. On its own, role="button" can
make any element (e.g. <p>, <span> or <div>
) appears as a button
control to a screen reader. Additionally, this role can be used in
combination with the aria-pressed attribute in order to create toggle
buttons.
另见注释
Where possible, it is recommended to use native HTML buttons
(<button>, <input type="button" /> and <input type="image" />
) rather
than the button role, as native HTML buttons are more widely supported
by older user agents and assistive technology. Native HTML buttons
also support keyboard and focus requirements by default, without need
for additional customization.
w3.org也有详细的解释aria-role
如前所述,ARIA 用于可访问性,role 属性不会对普通浏览器产生影响。
实现 ARIA 角色的最简单和实用的方法之一是使用地标。一些 ARIA 角色是地标,允许用户在屏幕阅读器中跳转到页面的特定部分。一些盲人用户发现这很有帮助,因为它可以帮助他们快速导航。描述了不同屏幕阅读器的支持和行为 here。
我看到了 ARIA 'role' 的文档,但无法理解。它到底是做什么的?比如说,我像这样在 table 中使用它:
<td role='button'>text</td>
这是否意味着此单元格将充当按钮?有人可以用更简单的术语解释一下吗?
您可以参考 MDN 上面写着:
The button role should be used for clickable elements that trigger a response when activated by the user. On its own, role="button" can make any element (e.g.
<p>, <span> or <div>
) appears as a button control to a screen reader. Additionally, this role can be used in combination with the aria-pressed attribute in order to create toggle buttons.
另见注释
Where possible, it is recommended to use native HTML buttons (
<button>, <input type="button" /> and <input type="image" />
) rather than the button role, as native HTML buttons are more widely supported by older user agents and assistive technology. Native HTML buttons also support keyboard and focus requirements by default, without need for additional customization.
w3.org也有详细的解释aria-role
如前所述,ARIA 用于可访问性,role 属性不会对普通浏览器产生影响。
实现 ARIA 角色的最简单和实用的方法之一是使用地标。一些 ARIA 角色是地标,允许用户在屏幕阅读器中跳转到页面的特定部分。一些盲人用户发现这很有帮助,因为它可以帮助他们快速导航。描述了不同屏幕阅读器的支持和行为 here。