Lessons · HTML and CSS · alt= on purpose
alt= on purpose
alt="" is a statement: this image carries no information, skip it.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
A decorative flourish announced on every page is noise, and noise is its own accessibility problem. Empty alt removes it from the tree entirely.
How to think about it
Use it for decoration, and for a photo whose caption already describes it -- duplicated text is a tax paid on every image on the page.
Worked example
<img src="x" alt="Ada Lovelace, 1843"><img src="x" alt=""><img src="x">Three different promises. The browser reports the first alt as its text, the second as an empty string, and for the third it reports that there is no alt attribute at all.
Your turn
Empty alt says skip it. A MISSING alt leaves the reader to
Write a page and watch it render
The trap
Empty is not the same as absent. Empty says 'nothing to see'; absent leaves the reader to guess, and many will read the file name out.
Practise alt= on purpose on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.