Alt text is an HTML attribute attached to a graphic element, typically an image, that provides a textual description of the visual content. Its main purpose is to ensure web content accessibility for people who cannot see images, such as blind users who rely on screen readers. When an image cannot be loaded or displayed, the alt text is shown in its place, offering substitute information.
In SEO, alt text is an often overlooked but potentially useful optimization element. Although it is not a direct or primary ranking factor, it helps make a page more understandable to search engines, improves user experience, and supports image discoverability in image search. Correct and descriptive use of the attribute therefore helps complete a well-structured organic SEO strategy.
What alt text is
Alt text, indicated in HTML with the alt attribute, is a string of text that describes the content of a non-text element. For images, it is placed inside the image tag itself. Its primary purpose is accessibility: it allows screen readers to vocalize what the image represents, enabling users with visual disabilities to understand the message conveyed.
Beyond accessibility, alt text serves as a fallback: if the image fails to load due to network issues or an incorrect path, the browser displays the text instead of the missing image. This way the user does not face a blank space but still receives an indication of the intended content.
Difference between alt text and caption
Alt text should not be confused with the caption or the image title. A caption is text visible to all users, placed near the image, that adds context or commentary. Alt text, on the other hand, is not meant to be shown under normal conditions and serves primarily those who cannot see the image. The two elements can coexist but have different purposes and audiences.
Why alt text matters in SEO
Search engines do not “see” images the way a human does: they analyze the surrounding textual context, the file name, the caption, and indeed the alt text. A relevant description provides crawlers with semantic information useful to understand what the image is about and, by extension, the topic of the page. This can help the content appear in image search and contribute to the overall relevance of the document.
Well-written alt text also improves user experience in situations of slow or failed image loading, reducing page ambiguity. Since user experience signals indirectly affect ranking, taking care of this attribute is part of on-page optimization best practices.
Alt text and accessibility
Web content accessibility guidelines recommend providing alt text for every image that conveys information. Purely decorative images, which add no content, should instead have an empty attribute so that screen readers ignore them. Distinguishing between informative and decorative images is therefore an essential step for correct alt text.
How to write good alt text
Good alt text is concise, descriptive, and consistent with the context in which the image appears. It should describe the function of the image on the page, not list every visual detail. If the image is a link, the alt text should indicate the destination or action, so that it is useful to those navigating with a screen reader.
It is preferable to avoid generic expressions like “image of” or “photo showing”, since the context already makes clear that it is an image. Better to focus on the essential information. The ideal length varies: for simple images a few words are enough, while for charts or diagrams a more detailed description may be necessary.
Common mistakes to avoid
Among the most common mistakes is inserting repeated and irrelevant keywords, a practice that does not help SEO and worsens accessibility. Another mistake is leaving the attribute empty on informative images, or filling it with the same text for all images on a page. Duplicating the caption in the alt text is also discouraged, since screen readers would read the same information twice.
Alt text, title, and file name compared
| Element | Visibility | Main function | SEO impact |
|---|---|---|---|
| Alt text | Not visible, shown if the image is missing | Describe the image for accessibility | Indirect, useful for image search |
| Caption | Visible to all users | Add context or commentary | Provides additional text to the page |
| Image title | Shown on mouse hover | Offer additional information | Marginal, often little considered |
| File name | Not visible on the page | Identify the file in the system | Useful if descriptive and relevant |
| Surrounding text | Visible to all users | Frame the image in the discourse | Relevant for semantic context |
Operational best practices
- Describe the function of the image in the context of the page, not every single visual detail.
- Keep the text concise, avoiding unnecessary introductory phrases.
- Use an empty attribute for purely decorative images.
- Indicate the destination when the image acts as a hyperlink.
- Avoid accumulating irrelevant or repeated keywords.
- Do not duplicate the caption within the alt text.
- Check consistency between alt text, file name, and surrounding content.
- Test the result with a screen reader to assess actual comprehensibility.
Frequently asked questions about alt text
Is alt text mandatory?
Technically the attribute can be omitted, but accessibility guidelines recommend specifying it for every informative image. For decorative images it should be left empty so that it is ignored by screen readers.
Does alt text improve ranking?
It is not a direct or decisive ranking factor. However, it helps make the page more understandable to search engines and can support visibility in image search.
How long should alt text be?
There is no fixed length. For simple images a few words are enough, while complex charts or diagrams may require a longer description, as long as it remains relevant and readable.
Can I include keywords in alt text?
Yes, if they are relevant to the image content and inserted naturally. Artificial keyword stuffing is discouraged and does not produce lasting benefits.
What is the difference between alt text and caption?
Alt text describes the image for those who cannot see it and is shown only if the image fails to load. A caption is text visible to everyone that adds context or commentary to the image.
What should I write for a decorative image?
For a purely decorative image, use an empty attribute so that screen readers ignore it. This avoids disturbing the listening experience with information that has no value for understanding the page.
Related entries:
Alt text Image SEO Image SEO Image SEO optimization Image SEO
