Agent Ready HTML

Alt text should replace the image, not describe it

In short

An image's alt attribute is its text replacement in the markup, and swapping every image for its alt should leave the page's meaning unchanged. Decorative images and images repeated by nearby text take an empty alt. Charts need text that conveys the same message. Gemini counts a small image as 258 tokens.

Published 18 November 2026

Write each alt as the words you would say in place of the image. The WHATWG HTML standard states the intent: replacing every image with the text of its alt attribute does not change the meaning of the page. Except where otherwise specified, the attribute must be specified, its value must not be empty, and the value must be an appropriate replacement for the image. The value should never contain text that could be considered the image's caption, title or legend, and it should not repeat information already given in the prose next to the image. One way to draft it, per the standard, is to imagine reading the page to someone over the phone without mentioning the image. Whatever you say instead of the image is typically a good start.

Decide what each alt carries

The W3C alt decision tree works through questions in order:

  • If the image contains text that is also present as real text nearby, or text shown only for visual effects, use an empty alt.
  • If the text in the image is not present otherwise, use the alt to include that text.
  • If the image is in a link or a button, and it would be hard or impossible to understand what the control does without it, the alt communicates the destination of the link or the action taken.
  • If the image contributes meaning and is a simple graphic or photograph, give a brief description that conveys that meaning.
  • If it is a graph or complex piece of information, include the information contained in the image elsewhere on the page.
  • If it shows content redundant to real text nearby, or is purely decorative or not intended for users, use an empty alt.

The tree states that it does not cover all cases. For controls, the WHATWG rules on links and buttons say that when a hyperlink or button has no textual content but contains images, the alt attributes must contain text that together conveys the purpose of the link or button. An icon placed beside a text label with the same meaning must have an alt that is present but empty. An icon with no text next to it must carry an equivalent textual label in its alt. A decorative image that is part of a site-wide design scheme should be specified in the site's CSS, not in the markup. MDN gives a concrete pair for action images: write alt="next page" instead of alt="arrow right".

Charts, diagrams and screenshots

When a flowchart, diagram, graph or map states something more clearly than prose, the standard's chart section says the lesser textual version must still be given. That text must be given in the alt attribute and must convey the same message as the image. The standard's financial report example puts the figures themselves in the alt and notes that "sales graph" would be inadequate alternative text:

<img src="sales.gif" title="Sales graph" alt="From 1998 to 2005, sales increased by the following percentages with each year: 624%, 75%, 138%, 40%, 35%, 9%, 21%">

If the paragraph before a chart already says everything the chart shows, the image is supplementary and its alt must be present but empty. For such a supplementary image, the standard says alt text made of just a caption would be wrong, and a caption can instead go in the title attribute or in the figure and figcaption elements. With figcaption, the standard treats the image as a graphical representation of a phrase or paragraph, so it then requires alternative text.

Screenshots follow the general case for key content. When detailed alternative text is possible, for example a series of screenshots in a magazine review, text that can substitute for the image must be given as the contents of the alt attribute. For images where thorough text is impractical, such as a complex fractal or a detailed topographical map, the alt must contain some suitable text but may be somewhat brief.

Related: How to move the answer into the initial HTML without a rewrite

Captions, title and filenames

The title attribute is not an acceptable substitute for alt, according to MDN's img reference. Its value usually appears as a tooltip, and you should not assume the user will ever see it, because the user may only have a keyboard or touchscreen. Present important information inline instead, and use figure and figcaption when an image needs a caption. The alt should not describe the presence of the image or its file name. When alt is missing, some screen readers may announce the file name instead.

Google's image guidelines call alt text the most important attribute for providing more metadata for an image. Google uses alt text along with computer vision algorithms and the contents of the page to understand an image's subject matter. It also extracts information from the page content, including captions and image titles, and asks that images sit near relevant text where possible. Filenames give Google very light clues: my-new-black-kitten.jpg is better than IMG00023.JPG. Avoid filling alt attributes with keywords, which Google says may cause a site to be seen as spam. Google can find images in the src attribute of an img element but doesn't index CSS images. For inline svg elements, Google points to the title element.

When a model receives the pixels

On the API, Claude takes images as image content blocks: a base64-encoded image, a URL reference to a hosted image, or a file_id from the Files API, per Anthropic's vision docs. An image costs ⌈width / 28⌉ × ⌈height / 28⌉ visual tokens. Claude 4.7 and later models have a 2,576 px long-edge limit and 4,784 visual tokens; all other models have 1,568 px and 1,568 tokens. Images larger than either limit are downscaled before processing, and Anthropic notes that resizing might make text less legible. Claude does not parse or receive any metadata from images passed to it. Anthropic also warns that Claude might hallucinate or make mistakes when interpreting low-quality, rotated, or very small images under 200 pixels.

Gemini counts differently. Images at or under 384 pixels in both dimensions count as 258 tokens, and larger images are tiled into 768x768 pixel tiles that each count as 258 tokens, per Google's token docs.

Markdown versions of the page

On a zone with Markdown for Agents enabled, a client that sends an Accept header with text/markdown gets the HTML converted to Markdown by Cloudflare's network. Cloudflare's documentation states that the YAML front matter takes its image field from the og:image meta tag, and only fields with a value are emitted. Non-content elements such as headers, footers, navigation, scripts and styles are stripped during pre-processing.

Related: How to see your site as a plain-fetch client

Check the page as text

Open the page's initial HTML and read each alt value in order, together with the text that comes before it. MDN describes this as an important accessibility test: the alt plus the preceding text should convey the same meaning as the image. After "On my travels, I saw a cute little animal:", an alt of "image" reads as nonsense, while "A Penguin on a beach." makes sense.

Related: Plain Fetch viewer

Sources

  1. WHATWG: HTML Standard: Images https://html.spec.whatwg.org/multipage/images.html, read 18 November 2026
  2. W3C WAI: An alt Decision Tree https://www.w3.org/WAI/tutorials/images/decision-tree/, read 18 November 2026
  3. MDN: <img> https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img, read 18 November 2026
  4. Google Search Central: Image SEO Best Practices https://developers.google.com/search/docs/appearance/google-images?hl=en, read 18 November 2026
  5. Anthropic: Vision https://platform.claude.com/docs/en/build-with-claude/vision, read 18 November 2026
  6. Google: Understand and count tokens (Gemini API) https://ai.google.dev/gemini-api/docs/tokens.md.txt, read 18 November 2026
  7. Cloudflare: Markdown for Agents https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/, read 18 November 2026

Last reviewed 18 November 2026