HTML5 中是否不需要 ALT 属性值来通过验证?
我正在看这个幻灯片 http://www.slideshare.net/CharJTF/structurals-semantics-controls-and-more-html-5-is-here-3523971 和幻灯片#14 有 3 个 img 标签示例
第三个没有价值。 HTML 5 允许吗?
I was looking at this Slideshow http://www.slideshare.net/CharJTF/structures-semantics-controls-and-more-html-5-is-here-3523971 and on slide #14 there are 3 examples of img tag
third one is without value. Is it allow in HTML 5?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
属性的解析规则从这里开始。请注意,遇到属性的第一个字符时的默认操作是这样的:
因此在 HTML5 中,
alt
和alt=""
是等效的。当图像完全是演示性的(尽管实际上在这种情况下,该图像应该包含在 CSS 中而不是包含在内容中),或者当它会重复已有的信息,从而损害屏幕阅读器用户的利益。在那里放置一个空字符串而不是完全忽略的一点是,如果没有
alt
属性,许多屏幕阅读器将读出src
中的完整路径属性来代替。The parsing rules for attributes start here. Note that the default action on encountering the first character of an attribute is this:
So in HTML5,
alt
andalt=""
are equivalent.It is acceptable to have an empty string value for an
alt
attribute when the image is entirely presentational (though really in that case, that image should be included with CSS rather than in the content), or when it would repeat information already available to the detriment of screen reader users. The point of putting an empty string there instead of leaving off altogether is that many screenreaders, if there isn't analt
attribute, will read out the full path in thesrc
attribute instead.HTML 5 现在定义 < code>foo 与
foo=''
相同HTML 5 now defines
foo
as being the same asfoo=''