When Alt Text is Required
What you'll learn: You'll discover which types of images actually need alt text and when it's acceptable to leave it empty.
Not all images need descriptive alt text—but the alt attribute itself is always required on every <img> element. The question is: when should it contain text, and when should it be empty?
Informative Images
These convey content or information that would otherwise be missing from the page. Examples include:
- Photos that illustrate the content (a product image in an article)
- Diagrams, charts, or infographics
- Images of text that can't be rendered as actual text
These need descriptive alt text.
Functional Images
These perform a function, like links or buttons. Examples include:
- Icons in navigation (home icon, search icon)
- Social media buttons
- Edit, delete, or action icons
These need alt text describing the action, not the image itself. For example, a magnifying glass icon should have alt="Search", not alt="Magnifying glass".
Decorative Images
These are purely visual and don't add meaning—like decorative borders, spacers, or background patterns that are part of the design.
These should have empty alt text: alt="" (not missing entirely). This tells screen readers to skip the image completely.
Think of it like this:
If you were reading the page content aloud to someone over the phone, would you need to describe this image for them to understand the page? If yes, it needs alt text. If no, use alt="".
Key Takeaway: Informative and functional images require descriptive alt text; decorative images should have alt="" to be ignored by screen readers—but the alt attribute must always be present.