Is <img src="[srcpath]" alt=""> the same as <img src="[srcpath]" alt> when it comes to accessibility?

111 Views Asked by At
<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?

2

There are 2 best solutions below

2
On BEST ANSWER

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 empty alt="" attribute

However.. if I were to look at the DOM inspector in Chrome and look at an img that had alt="" 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 the alt attribute, and keeping consistency in your alt techniques with respect to the HTML specifications.

0
On

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":

Just the attribute name. The value is implicitly the empty string.