图片alt属性的最佳做法 [英] Image alt attribute best practices

查看:93
本文介绍了图片alt属性的最佳做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< img> 标签上的 alt 属性的预期用途究竟是什么?



它应该描述图像,还是应该为屏幕阅读器(以及关闭图像的人)提供有意义的替换文本?

例如,如果我的网站上有一个简短的人物传记,并且包含他们的一张小照片,那么让视障用户有John Smith照片向他们宣读是否真的有意义?

p>

解决方案

HTML 5规范有一个巨大部分

基本上,如果你根本没有使用过图像,那么 alt 属性应该是文本的内容。如果您的图片纯粹是装饰性的,您可以使用 alt =。描述出现在标题属性中。


What exactly is the intended use of the alt attribute on <img> tags?

Should it describe the image, or should it provide meaningful replacement text for screen-readers (and people who have images turned off)?

For example, if I have a short biography of a person on my website, and include a small photo of them, is it really meaningful to visually impaired users to have "Photo of John Smith" read out to them?

解决方案

The HTML 5 spec has a huge section on this.

Basically, the alt attribute should be what would be there as text if you hadn't used an image at all. If your image is purely decorative, you can use alt="". A description goes in the title attribute.

这篇关于图片alt属性的最佳做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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