html – aria-label和title属性有什么区别?

参见英文答案 > What is aria-label and how should I use it?3
我习惯于在我的链接/按钮/ …上使用title =“”属性来详细说明.但是,由于可理解的原因,引导程序使用了很多aria-label =“”属性,据我所知.

所以我想起来创建如下的按钮:

<button
    id="show-raw-result"
    class="btn btn-default btn-sm btn-twigfiddle"
    title="Result was not easily readable so it has been automatically cleaned up,use this button to see the result raw"
    aria-label="Result was not easily readable so it has been automatically cleaned up,use this button to see the result raw">
    <span class="glyphicon glyphicon-asterisk"></span> Show raw result
</button>

但是,复制/粘贴标题来创建一个咏叹调标签看起来很丑陋.我应该选择哪一个,为什么?

解决方法

ARIA标签用于您网站的残疾游客. Bootstrap非常好,认情况下它们支持它.

Accessible Rich Internet Applications (ARIA) defines ways to make Web
content and Web applications (especially those developed with Ajax and
JavaScript) more accessible to people with disabilities. For example,
ARIA enables accessible navigation landmarks,JavaScript widgets,form
hints and error messages,live content updates,and more.

资料来源:https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA

要回答你的问题,你应该使用哪一个,只使用标题属性.因为如果您的鼠标移动按钮并将标题文本显示为工具提示,则使用此属性.以这种方式不支持aria标签.

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些