I've been told it's better to have alt="" on images that don't have alt text, rather than omitting the alt attribute altogether. This seems a little strange to me, but I'm not accessibility expert!

The justification is from the W3C (https://www.w3.org/WAI/tutorials/images/decorative/):

Decorative images don’t add information to the content of a page. For example, the information provided by the image might already be given using adjacent text, or the image might be included to make the website more visually attractive.

In these cases, a null (empty) alt text should be provided (alt="") so that they can be ignored by assistive technologies, such as screen readers. Text values for these types of images would add audible clutter to screen reader output or could distract users if the topic is different from that in adjacent text. Leaving out the alt attribute is also not an option because when it is not provided, some screen readers will announce the file name of the image instead.

However, I have questions:

  1. How do we know that images without an alt are decorative?
  2. Is there ever a time when the behavior of assistive technologies with an img that has no alt (vs empty alt) is helpful behavior?
CommentFileSizeAuthor
#2 panopoly_images-empty-alt-2905972-2.patch602 bytesdsnopek

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new602 bytes

If this turns out to be the right thing to do, here's a patch.

cboyden’s picture

Issue tags: +Accessibility

How do we know that images without an alt are decorative?

We don't, but we do know that the site editor didn't bother to put any text in. In this case, if the alt attribute is not output for an image, a screenreader will read out the filename of the image. It's just as likely to be something like "IMG-09683.jpg" as it is to be anything useful. If the alt attribute is output, and is empty, then a screenreader will not announce anything for the image.

Drupal 8 addresses this by making the alt field required by default on images. Overall, alt text is a content issue. Site editors have the opportunity to add alt text when they upload a new image, or when they edit a managed image from the Files tab, or when they insert an existing managed image into a WYSIWYG field. The help text on the field states "Alternative text is used by screen readers, search engines, and when the image cannot be loaded. By adding alt text you improve accessibility and search engine optimization." We're sort of kicking the can down the road when we output an empty alt attribute instead of leaving off the alt attribute, but it's arguably a better UX to leave it empty and un-announced.

Is there ever a time when the behavior of assistive technologies with an img that has no alt (vs empty alt) is helpful behavior?

In my opinion, not really.

mgifford’s picture

+1 @cboyden

I've never heard of any instance where no alt (vs empty alt) is at all helpful for any reason. If an image doesn't have an alt text it should default to alt="".

jfurnas’s picture

As per HTML5 specification, img alt="" and img alt are equivically the same. As per accessibility, an alternative text is required, unless it is a decorative image in which case the alternative text can be left blank.

Also, in testing with Jaws and NVDA screen readers, the abscence of an alt tag altogether results in the screenreader completely bypassing the image, and reading back nothing.

So to summarize, alt="" or alt can be used IF the image is decorative, the complete ommission of the alt attribute all together is not accessible.

cboyden’s picture

Status: Needs review » Reviewed & tested by the community

We've been using this patch for quite a while and it works as expected.

  • dsnopek committed bcd3bb9 on 7.x-1.x
    Issue #2905972 by dsnopek, cboyden: Use empty alt="" on images without...
dsnopek’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! Committed :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.