Skip to content

Image alt text for SEO and AI search: how to write it

How to write image alt text for SEO and AI search: informative, decorative, functional and complex images, plus filenames, formats and a quick audit.

By Crawlito · 8 min read

In short

  • Google says it uses alt text together with computer vision and the content of the page to understand an image, and it advises against filling alt attributes with keywords.
  • W3C's image tutorial sorts images into types: informative images get a short description, decorative images get empty alt text (alt=""), functional images get the action or destination, and complex images get a long description in the page text.
  • Google does not index CSS images, so an image that carries meaning belongs in an img element, with alt text, not in a CSS background.
  • Google's image sitemap documentation presents sitemaps as a way to surface images Google might not otherwise find, such as images loaded through JavaScript; it does not say they are required.
  • OpenAI's crawler documentation does not mention images or alt text, so for AI search the safe assumption is that alt text is useful when it is in the HTML, not that any assistant is known to rank it.
On this page

Write alt text that says what the image adds to the page, in a short phrase or sentence, and write nothing (alt="") when the image is only decoration. Google says it uses alt text along with computer vision and the content of the page to understand what an image is about, and the same text is what screen readers announce. One piece of text serves both audiences, so write it for the person who cannot see the image.

This guide covers the four kinds of image you will meet, how to write alt text for each, what filenames and captions add, which formats and loading methods crawlers can still find, and how to audit a site.

What is alt text for, and what does Google say it uses?

The alt attribute is the text alternative for an img element. It is read aloud by screen readers and available to anything that parses your HTML.

In its image SEO guide, Google says:

  • It uses alt text along with computer vision algorithms and the page's content to understand the subject of an image.
  • Alt text is the most important attribute for image metadata, and it should be useful, information-rich and fit the page.
  • When an image is a link, the alt text works as anchor text for the link.
  • You should avoid filling alt attributes with keywords, because that makes for a poor experience and may be treated as spam.

For AI assistants the picture is thinner. OpenAI's crawler documentation does not mention images or alt text for OAI-SearchBot or ChatGPT-User. At the time of writing, the bot pages from Anthropic and Perplexity do not mention them either. What is safe to say: alt text that is in the HTML your server sends can be read by any tool that reads HTML. Whether a given assistant uses it is not documented. Checking that the text is in the raw HTML is covered in raw HTML vs rendered HTML.

How do you write alt text for informative images?

An informative image shows a concept, product or fact the reader needs. W3C's image tutorial says such an image can usually be covered by a short phrase or sentence, and that the text should convey the meaning in context rather than act as a literal description. The same photo may need different alt text on different pages.

Google's own examples show the range, from a missing alt and a keyword-stuffed one (both labelled bad) to alt="puppy" (better) and alt="Dalmatian puppy playing fetch" (best).

SituationWeak altBetter alt
No alt attribute<img src="shoe.jpg">alt="Side view of a green trail shoe with a rock plate in the sole"
Keyword listalt="trail shoes cheap trail shoes buy trail shoes"alt="Green trail running shoe, side view"
Describes the filealt="IMG_0023"alt="Hiker tying a boot on a rocky ridge"

A few working rules:

  1. Say what the image contributes: the product detail, the step, the person doing the thing.
  2. Keep it short. Neither Google's guide nor the W3C tutorial sets a character limit, so there is no number to hit.
  3. Match the page. If the surrounding text already says what the image shows, you may not need to repeat it.
  4. Put a keyword in only where it truly describes the image.

What about decorative, functional and complex images?

W3C's image tutorial separates images by purpose, and the right alt text depends on the type, not on the picture.

TypeWhat it isAlt text
InformativePhoto, illustration or diagram that carries meaningA short description of the meaning
DecorativeAdds visual interest but no informationEmpty: alt=""
FunctionalImage inside a link or buttonThe action or destination
Image of textWords rendered as pixelsThe same words, if they appear nowhere else
ComplexChart, graph or detailed diagramA short description plus a long description in the page

Decorative images

W3C says an image whose only job is decoration gets a null text alternative, written alt="", so screen readers skip it. Do not delete the attribute: W3C notes that some screen readers announce the file name when alt is missing.

html
<img src="/img/divider-wave.svg" alt="">

Whether an image is decorative is your call as the author. A photo placed beside a sentence that already describes it can be decorative. The same photo identifying a plant the text never names is informative.

Functional images

For an image in a link or button, describe what happens, not how the icon looks. W3C's examples: a printer icon becomes "Print this page", and a magnifying-glass search button becomes "Search".

html
<a href="/"><img src="/img/logo.svg" alt="Acme home"></a>

If the link already has visible text next to the logo, W3C says the logo gets empty alt so the words are not announced twice. An image-only link with no alt gives a crawler no alt text to use as anchor text, since Google says alt text serves that role for linked images.

Images of text and complex images

W3C advises avoiding text in images except for logos; if you use one, repeat its words in the alt text, unless the same words appear elsewhere on the page. The text in images guide covers why this matters for crawlers.

For charts, diagrams and maps, W3C describes a two-part alternative: a short alt that identifies the image, then a long description with the values, trends and relationships, placed where everyone can read it. One way to do it:

html
<figure>
  <img src="/img/signups-2026.png"
       alt="Line chart of monthly signups, January to October 2026. Data in the table below.">
  <figcaption>Monthly signups, January to October 2026</figcaption>
</figure>
<table><!-- the same numbers as real rows and cells --></table>

W3C says the alt text can tell the reader where the long description lives. A table is also something a text-only crawler can read, unlike the PNG.

Do filenames, captions and surrounding text matter?

They give context, and Google documents some of it:

  • Filenames. Google recommends short, descriptive names: my-new-black-kitten.jpg rather than IMG00023.JPG. Avoid generic names like image1.jpg or 1.jpg.
  • Surrounding text. Google says it extracts information about an image's subject from the content of the page, including captions and image titles, and advises placing images near relevant text.
  • Captions. A visible caption is page text, so it adds context. W3C's decision tree says an image that repeats real text nearby gets an empty alt; if a caption already says everything the image says, that may apply, and if the alt and the caption cover different things, keep both.
  • Headings and structure. Images sit better under a heading that names their topic, as in headings, landmarks and link text.

Which image formats and loading methods can crawlers still find?

Alt text only helps if the crawler can find the image element. From Google's guide:

  • Formats. Images in an img src can be BMP, GIF, JPEG, PNG, WebP, SVG or AVIF. The file extension should match the real file type.
  • Responsive images. srcset, sizes and picture are fine, but some browsers and crawlers do not understand them, so always give a fallback URL in src.
  • CSS images. Google does not index CSS images. W3C suggests CSS backgrounds for decorative images where possible; anything meaningful needs an img.
  • Data URIs. Supported, but they can considerably increase page size.
  • Inline SVG. Use a title element inside the svg, referenced with aria-labelledby.

On lazy loading, Google's lazy-loading guide says images should load when they enter the viewport, not depend on scrolling or clicking, and that you can confirm it works when the image URLs appear in the src attribute of img elements in the rendered HTML. The pattern that hides the real URL until a script runs is dissected in lazy loading, tabs and accordions.

When is an image sitemap worth adding?

Google's image sitemap documentation describes them as a way to tell Google about images it might not otherwise find, such as images loaded through JavaScript. It does not say they are required.

The details that matter:

  • Add image tags to an existing sitemap or use a separate one; the page says either approach is equally fine for Google.
  • The documentation's required tags are image:image, which wraps each image, and image:loc, which holds the image URL. One url entry can hold up to 1,000 image:image tags.
  • The caption, geo location, title and license tags have been removed from the documentation, so do not spend time on them.
  • Images can sit on another domain, such as a CDN, if you verify both domains in Search Console. Check that robots.txt does not block the images you want indexed.
xml
<url>
  <loc>https://example.com/shoes/ridge</loc>
  <image:image>
    <image:loc>https://cdn.example.com/img/ridge-side.jpg</image:loc>
  </image:image>
</url>

If your images are ordinary img tags in server-rendered HTML, the documentation does not say you need one. If they come from a script or a gallery widget, it is worth adding. General sitemap rules are in XML sitemaps for AI discovery.

How do you audit alt text across a site?

Start with the pages that matter most. Fetch the raw HTML, flatten it to one line, and list every image tag:

bash
curl -sL https://example.com/page | tr '\n' ' ' | grep -oiE '<img[^>]*>'

Then split the list into two problems. Images with no alt attribute at all:

bash
curl -sL https://example.com/page | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -viE '[[:space:]]alt='

And images with empty alt, which you then check by eye to confirm each one is really decoration:

bash
curl -sL https://example.com/page | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -iE 'alt=""'

Go through the results with these questions:

  1. Is any attribute missing entirely? Add alt, empty or filled.
  2. Is an empty alt on something that carries meaning, such as a banner, chart, or image-only link?
  3. Is the alt a filename, a keyword list or a copy of the page title?
  4. Do src values hold real URLs, or placeholders with the real URL in data-src?

The command only sees images in the raw HTML. Images a script adds later do not appear, which is the same gap described in raw vs rendered HTML. For a larger site, export image tags with a crawler of your choice and sort by empty or missing alt.

Frequently asked questions

Is there a character limit for alt text?

Neither Google's image guide nor W3C's tutorials gives one. W3C describes informative alt as a short phrase or sentence, and says anything longer, like a chart's data, belongs in a long description on the page.

Should every image have alt text?

Every img should have an alt attribute. Meaningful images get a description; decorative ones get alt="". W3C advises against omitting the attribute because some screen readers then announce the file name.

Do ChatGPT, Claude and Perplexity read my alt text?

At the time of writing, their operators' bot pages do not mention it. OpenAI's, Anthropic's and Perplexity's crawler pages say nothing about images or alt text. Alt text in the raw HTML is available to any tool that parses HTML, but treat it as good markup, not as a known citation factor.

Does putting my keyword in alt text help SEO?

Google says alt text should be useful and information-rich, and that stuffing keywords is a poor experience and may be seen as spam. Use the keyword only where it describes the image.

Do CSS background images need alt text?

They cannot have it, and Google does not index CSS images. W3C notes decorative images can be done in CSS. If the image carries information, use an img element with alt text.

Check what a crawler receives

Run the audit commands on your top few pages first. For a second view of what a crawler gets from a page, the free single-page check needs no account, and a full audit covers up to 500 pages with human review and a PDF of prioritized fixes.

Filed under Structure and schema. Topics: html, accessibility, google, checklist