role="tooltip"重要吗?

Is role="tooltip" important?

  1. 大多数屏幕阅读器默认阅读自定义工具提示信息。 role="tooltip" 似乎没有做任何额外的事情,就像它没有通知用户它的工具提示。为什么我们需要为工具提示容器使用 role="tooltip"?有什么具体目的吗?
  2. IE11 中的 NVDA 未读取工具提示信息。有什么技巧可以解决吗?

这是我的代码:

<div class="ttipcontainer">
  <button title="" class="co_tooltipElement" id="newButton05-2" aria-describedby="coid_accessibleTooltip_1"> Recent Searches </button> 
  <span tabindex="-1" class="co_accessibilityLabel" id="coid_accessibleTooltip_1" aria-hidden="true" role="tooltip">Shows information of your recent searches</span>
</div>

Heydon Pickering 有一个很好的写作指南Accessible Toggle Tips。他在其中描述了为什么我们将 role=tooltip 放在元素上:

Note the use of the tooltip role. In practical terms, all this role offers is an assurance that aria-describedby works reliably where supported. As Léonie Watson writes, ARIA labels and descriptions sometimes don't work with all elements unless you incorporate an appropriate role. In this case, the most important role is the implicit button role of the subject element, but role="tooltip" may extend support for this labeling method in some software.

因此,虽然它没有提供太多额外信息,但它确实帮助 aria-describedby 指向具有有效角色的元素,这有助于确保它对某些屏幕阅读器正常工作。