HTML5是否不需要ALT赋予值才能通过验证? [英] Is value for ALT atrribute not required in HTML5 to pass validation?

查看:56
本文介绍了HTML5是否不需要ALT赋予值才能通过验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看此幻灯片.请注意,遇到属性的第一个字符时的默认操作是:

在当前标记令牌中启动一个新属性.设置该属性的名称为当前输入字符,其值为空细绳.切换到属性名称状态.

因此在HTML5中, alt alt =" 是等效的.

当图像完全是表示形式时,对于 alt 属性使用空字符串值是可以接受的(尽管在那种情况下,该图像应包含在CSS中而不是内容中),或何时重复出现已经对屏幕阅读器用户有害的信息.在这里放置一个空字符串而不是完全放弃它的目的是,如果没有 alt 属性,许多屏幕阅读器将读出 src 中的完整路径属性.

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?

解决方案

The parsing rules for attributes start here. Note that the default action on encountering the first character of an attribute is this:

Start a new attribute in the current tag token. Set that attribute's name to the current input character, and its value to the empty string. Switch to the attribute name state.

So in HTML5, alt and alt="" 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 an alt attribute, will read out the full path in the src attribute instead.

这篇关于HTML5是否不需要ALT赋予值才能通过验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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