图标字体可访问性:具有aria标签的父级跨度或仅具有sr的同级跨度

时间:2019-07-09 07:01:09

标签: html accessibility wai-aria screen-readers icon-fonts

我有一个不是装饰性的图标,尽管在层次结构中有一个交互式元素,但它并不直接位于交互式元素中。

类似这样的东西:

<button type="button">
    <div> Some info </div>
    <div> other info </div>
    <i class="material-icons"> icon </i>
</button>

此图标显示有关此项目状态的信息。

要使其更易于访问,最好将结构更改为此:

<button type="button">
    <div> Some info </div>
    <div> other info </div>
    <span aria-label="the actual status">/
     <i class="material-icons"> icon </i>
    </span>
</button>

或者这个:

<button type="button">
    <div> Some info </div>
    <div> other info </div>
    <i class="material-icons"> icon </i>
    <span class="sr-only"> the actual status </span>
</button>

1 个答案:

答案 0 :(得分:3)

  

我有一个图标...不是直接位于交互式元素中

这不是您的代码示例所显示的。

<button>
   <i>
</button>

您的图标肯定包含在一个交互式元素中。当屏幕阅读器用户使用Tab键点击按钮时,全部将包含在