i标签的Alt或title属性 [英] Alt or title attribute for i tag

查看:339
本文介绍了i标签的Alt或title属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 font-awesome 并显示其字体,如下所示:

I use font-awesome and display their fonts like that:

<i class="icon-lock"></i>

这将显示一个漂亮的小锁符号.为了让用户知道确切的含义,我尝试添加诸如title和alt之类的属性,但无济于事.

This will display a nice little lock symbol. For the user to know what exactly that means, I tried adding attributes such as title and alt, but to no avail.

我可以为<i>标记使用任何属性,该属性执行与alt的图像和链接的标题相同的任务吗?

Is there any attribute I can use for the <i> tag that executes the same task as alt for images and title for links?

推荐答案

您可以在i元素上使用title属性,例如任何元素,例如

You can use the title attribute on an i element, like any element, e.g.

<i class="icon-lock" title="This symbolizes your being locked inside"></i>

是否有帮助是一个更困难的问题.浏览器通常在鼠标悬停时将title属性值显示为工具提示",但是用户为什么将鼠标悬停在图标上?这些工具提示的可用性很差;所谓的CSS工具提示通常效果更好.

Whether it helps is a more difficult issue. Browsers usually show the title attribute value as a "tooltip" on mouseover, but why would the user mouse over the icon? And such tooltips are of poor usability; so-called CSS tooltips often work better.

屏幕阅读器可以为用户提供对title属性的可选访问权限,但我不确定它们如何处理内容为空的元素.

Screen readers may give the user optional access to title attributes, but I’m not sure what they do with elements with empty content.

这篇关于i标签的Alt或title属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆