alt attribute

Web design & UX

The alt attribute contains a text description for an image. It is read aloud when someone uses a screen reader and displayed when the image fails to load. Search engines use it to categorize the image content.

A good alt text describes what can be seen in the context of the page. Bad: "Image1". Also bad, because over-optimized: "Cheap web hosting server Düsseldorf". Good: "Server cabinet in the data center Düsseldorf with blue status lights".

A rule of thumb for length: one sentence, a maximum of about 125 characters. If you can't describe the image content in one sentence, you should consider whether the information would be better suited to the body text.

The important exception is this: purely decorative images, such as a dividing line or a background pattern, are given an empty alt attribute. This allows the screen reader to skip them instead of reading out meaningless descriptions. A missing attribute is different from an empty one, because in the latter case the software often reads out the filename.

Back to the glossary