前端笔记本

HTML5中的aria与role

2017-08-30  本文已影响9人  大乔是个美少女

这些都是HTML5针对html tag增加的属性,一般是为不方便的人士提供的功能,比如屏幕阅读器。
role的作用是描述一个非标准的tag的实际作用。比如用div做button,那么设置div 的 role="button",辅助工具就可以认出这实际上是个button。
aria的意思是Accessible Rich Internet Application,aria-*的作用就是描述这个tag在可视化的情境中的具体信息。比如:

<div role="checkbox" aria-checked="checked"></div>  

辅助工具就会知道,这个div实际上是个checkbox的角色,为选中状态。

<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expended="false">
  <span class="caret">Dropdown </span>
</a>

辅助工具就会知道,这个a实际上是个button的角色,为非选中状态。

上一篇 下一篇

猜你喜欢

热点阅读