问题描述
我注意到在所有使用 button
元素的 Bootstrap 示例中,它们包括 role="button"
(和 type="button"
>),例如:
<button id="dLabel" type="button" role="button" data-toggle="dropdown"aria-haspopup="true" aria-expanded="false">下拉触发器 <span class="caret"></span>按钮><ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">...
辅助功能软件难道不知道 button
元素是用来充当按钮的吗?我有什么理由应该在我的代码中包含 role="button"
和/或 type="button"
?
许多 HTML5 元素带有默认的隐式 ARIA 语义,并且显式设置这些默认值是不必要且不推荐".
因此,设置 role="button"
是不推荐"的,但允许.它可能帮助那些支持 WAI-ARIA 但不支持 HTML5 的老用户代理.
I've noticed in all of Bootstrap's examples using button
elements, they include role="button"
(and type="button"
), such as:
<div class="dropdown">
<button id="dLabel" type="button" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Dropdown trigger <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
...
</ul>
</div>
Won't accessibility software already know that a button
element is meant to act as a button? Is there any reason I should include role="button"
and/or type="button"
in my code?
Many HTML5 elements come with default implicit ARIA semantics, and explicitly setting these default values is "unnecessary and not recommended".
Looking at the button
element, you can see that it has the button
role by default.
So, setting role="button"
is "not recommended", but allowed. It might help older user agents that support WAI-ARIA but not HTML5.
这篇关于我需要角色=“按钮"吗?在<按钮>上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!