我已经在所有Bootstrap的示例中使用button
元素,它们包括role="button"
(和type="button"
),例如:
<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>
可访问性软件是否已经知道button
元素是要用作按钮的?我应该在代码中包含role="button"
和/或任何原因type="button"
吗?
许多HTML5元素带有默认的隐式ARIA语义,并且显式设置这些默认值是“不必要的,不建议使用”。
查看button
element,您可以看到它默认具有button
角色。
因此,role="button"
“不建议”设置,但允许设置。它可能会帮助支持WAI-ARIA但不支持HTML5的旧用户代理。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句