<img src="[srcpath]" alt="">
<img src="[srcpath]" alt>
That is to say:
Are those both considered null values for image alt
text? Or must you ensure the alt=""
is present?
<img src="[srcpath]" alt="">
<img src="[srcpath]" alt>
That is to say:
Are those both considered null values for image alt
text? Or must you ensure the alt=""
is present?
Both have the empty string as value, so they are equivalent.
HTML5 defines that attributes can be specified in four different ways, among them the "Empty attribute syntax":
You should use the
alt=""
attribute. Each example of the null alt attribute in the specs for providing alternative text for an image explicitly uses it. Here's another resource on the emptyalt=""
attributeHowever.. if I were to look at the DOM inspector in Chrome and look at an
img
that hadalt=""
in the source code, I would see<img src="[srcpath]" alt>
.The Failure Criterion F65 in the WCAG 2.0 standards note that the presence of the
alt
attribute is sought. It does not clarify whether or not the alt attribute must be explicitly declared as empty (alt=""
) for HTML5 standards, and as long as you're using the HTML according to the spec, having<img src="[srcpath]" alt>
would technically be considered accessible.So in summary - yes, they technically are the same when it comes to accessibility, but I'm not one to derive from given instruction. By using
alt=""
, you are being aware of the purpose of thealt
attribute, and keeping consistency in your alt techniques with respect to the HTML specifications.