简体   繁体   English

在某些情况下,对于html img标签,alt =“”是否合适?

[英]Is alt=“” appropriate in some situations for html img tag?

We have a project that is all about web accessibility compliance. 我们有一个关于Web可访问性合规性的项目。 About a week from launch we have the accessibility committee reviewing our site to give the final thumbs up. 从发布开始大约一周后,我们让无障碍委员会审查我们的网站,以给予最后的赞许。 However, they reported back to us that we should set alt="" on some of our icons because they do not provide any additional content to the site and thus are merely distracting to a screen reader but yield no benefit. 然而,他们向我们报告说,我们应该在我们的一些图标上设置alt =“”,因为它们不会向网站提供任何额外的内容,因此只会分散屏幕阅读器的注意力,但不会产生任何好处。

  1. Is this correct? 它是否正确?
  2. I was under the impression alt was a required attribute of img? 我的印象是alt是img的必需属性? Sure alt="" on an img tag would include the alt attribute but is this valid ? 在img标签上确定alt =“”将包含alt属性,但这是否有效?

Comments are appreciated. 评论表示赞赏。

If the icons provide any functionality (user-clickable or something), I'd recommend setting a descriptive alt value. 如果图标提供任何功能(用户可点击或其他),我建议设置描述性alt值。 If they are just decorative, then alt="" is valid. 如果它们只是装饰性的,那么alt=""是有效的。

From the standard : 标准

While alternate text may be very helpful, it must be handled with care. 虽然备用文本可能非常有用,但必须小心处理。 Authors should observe the following guidelines: 作者应遵守以下准则:

  • Do not specify irrelevant alternate text when including images intended to format a page, for instance, alt="red ball" would be inappropriate for an image that adds a red ball for decorating a heading or paragraph. 在包含用于格式化页面的图像时,请勿指定不相关的替代文本,例如,alt =“red ball”将不适合添加红色球来装饰标题或段落的图像。 In such cases, the alternate text should be the empty string (""). 在这种情况下,备用文本应为空字符串(“”)。 Authors are in any case advised to avoid using images to format pages; 无论如何,建议作者避免使用图像来格式化页面; style sheets should be used instead. 应该使用样式表。
  • Do not specify meaningless alternate text (eg, "dummy text"). 不要指定无意义的替代文本(例如,“虚拟文本”)。 Not only will this frustrate users, it will slow down user agents that must convert text to speech or braille output. 这不仅会使用户感到沮丧,还会减慢必须将文本转换为语音或盲文输出的用户代理。

根据这个来源: http//msdn.microsoft.com/en-us/library/ms228004( v = VS.100) .aspx# guideline_11__providing_alternate_text_for_images省略alt属性会使一些屏幕阅读器发出文件名并分散用户的注意力,这就是建议将alt设置为空字符串的原因。

The alt attribute is always required if you want your code to pass validation, however it's not necessary for the alt attribute to have a value. 如果您希望代码通过验证,则始终需要alt属性,但alt属性不必具有值。

If you're using images for page decoration (for example, rounded corners or shadows for browsers that don't support CSS3), these images should be in the CSS rather than inside <img> tags in the html. 如果您正在使用图像进行页面修饰(例如,对于不支持CSS3的浏览器使用圆角或阴影),这些图像应该在CSS中,而不是在html中的<img>标记内。 However, there are cases when you may have images that should be included as actual images in the html, even though there is no meaningful way to describe them for screen reading software. 但是,有些情况下您可能会将图像作为实际图像包含在html中,即使没有有意义的方法来描述它们用于屏幕阅读软件。 In this case, w3.org says that it's okay to use alt="" . 在这种情况下,w3.org说可以使用alt="" 1 1

1: http://www.w3.org/QA/Tips/altAttribute 1: http//www.w3.org/QA/Tips/altAttribute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM