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

前端之家收集整理的这篇文章主要介绍了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标签.

原文链接:https://www.f2er.com/html/230683.html

猜你在找的HTML相关文章