I was looking through Chrome's Developer Tool's elements tab when something caught my eye and prompted this question.
Though meaningful alt
attributes on img
tags are a necessary expectation for accessibility (<img src="/path/to/beauty.png"
alt="Olivia Culpo won the Miss USA 2012 contest"/>
), I have seen it often advised that the alt
attribute of "spacer", or other "decorative" images should be given a blank value: <img src="/images/spacer.gif" alt
=""/>
These questions are just for decorative images:
<img src="/images/spacer.gif"
alt/>
If you run <img src="..." alt />
through the validator, it throws an error. The alt
attribute needs a value, even if it is null alt=""
. Usually when an image doesn't have an alt, some assistive technology announces the path to the image.
So <img src="..." alt />
is the same as <img src="..." />
. Usually the word used is decorative vs trival, but it is probably the same idea. These type of images should have a null alt.