html - 为什么我们要在 html 中向内容图像添加 alt 属性?

标签 html css

<body>
  <img src="cake.png" alt="Cake Photo">
</body>

在上面的代码中写alt属性的目的是什么,如果是为了可读性那么我们可以在src部分显示明确的意图。

最佳答案

"The alt attribute specifies an alternate text for an image, if the image cannot be displayed.

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Tip: To create a tooltip for an image, use the title attribute!"

http://www.w3schools.com/tags/att_img_alt.asp

关于html - 为什么我们要在 html 中向内容图像添加 alt 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31766485/

相关文章:

javascript - jQuery offset().top 未定义

html - 在某些情况下,如何防止侧导航的第一个元素隐藏在顶部导航下方?

html - 内联表单中的多个输入框

javascript - 加载时底部弹出

html - 图像不在中间

javascript - 单击按钮时如何获取输入值

html - 为什么png文件没有出现在html中

javascript - HTML 网格在我的网页右侧创建了烦人的边距

css - 如何使用 selenium 获取页面上某些文本的 HTML 标记

css - MacOS Chrome 水平滚动条不消失