What does the alt attribute mean?
Alt is an attribute of the <img> element in HTML, present since the earliest versions of the spec. Its job is to offer a text alternative to visual content: where the image can't be perceived, the alt text takes its place. Along with the src attribute, it's one of the few attributes accessible markup can't do without.
In modern frameworks and content management systems, the attribute often gets auto-filled from the file name when nobody sets it by hand, which rarely produces a useful description. It's often confused with two other elements that look similar but serve different purposes. The title attribute shows a tooltip on mouse hover, meant for mouse users, not for screen readers, which don't announce it by default. The figcaption element is a visible caption inside a figure, meant for every visitor, not only for someone who can't see the image.
The requirement to provide a text alternative isn't a loose recommendation: it's Success Criterion 1.1.1 ("Non-text Content") of the W3C's WCAG guidelines, the basis for most web accessibility regulations.
A real case: the same photo, three alt texts
alt="beach"Accurate and empty. It says neither who, nor where, nor what is happening.
alt="child with umbrella on the beach"Describes the scene, but fits Cádiz or Rimini just as well. It misses the one thing this page contributes.
alt="Child with a beach umbrella at Cala Millor beach, Mallorca"Names the specific place, which is exactly what the page is about. And it stays an honest description of what is visible.
alt="mallorca beach hotel offer holiday cheap booking"This no longer describes anything; it is keyword stuffing, and Google treats it as spam. Rule of thumb: what is useless to someone who cannot see the image is useless to the search engine too.
