“Alt tag” is a common informal phrase, but alt is an attribute on img. It provides a text alternative for the image’s purpose in context. A good alternative is not a list of search keywords or a universal description of every visible detail.

Describe the information this image adds

The illustration shows an upward/downward outline rather than a real measured chart. Its alternative describes that illustration accurately, without inventing data.

Informative imageLink

HTML and CSS

HTML

<img
  src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22180%22%20height%3D%22100%22%3E%3Crect%20width%3D%22180%22%20height%3D%22100%22%20fill%3D%22%23eff6ff%22%2F%3E%3Cpath%20d%3D%22M20%2080%20L70%2030%20L100%2060%20L130%2020%20L165%2080%20Z%22%20fill%3D%22%232563eb%22%2F%3E%3C%2Fsvg%3E"
  width="180"
  height="100"
  alt="Blue outline with three peaks of different heights"
/>
<p>A practice illustration, not a data chart.</p>

CSS

img {
  display: block;
  max-width: 100%;
  height: auto;
}

Edit HTML or CSS to update the preview as you type. Copy code snippet copies the selected tab. Preview spacing and font defaults are not included.

When the image is decorative

Use alt=”” when an image adds no information beyond nearby text or is purely decoration. Omitting alt is different: some assistive technology may announce the filename or an unhelpful URL. Do not repeat a caption word for word when that gives the reader the same message twice.

For a linked image with no other link text, the alternative should explain the link’s purpose. If a logo is the only content in a homepage link, the organization/home destination matters more than saying “logo.” If a text label already names the link, a decorative image inside it may use an empty alternative.

Complex charts may need a concise alt plus a nearby detailed description or data table. For important text shown in an image, provide that text or equivalent information. Alt cannot compensate for inaccessible controls, missing labels, or a chart whose data is unavailable anywhere else.

Search and sharing

Google uses alt alongside computer vision and surrounding page content; it is inaccurate to say search engines cannot understand images. Descriptive alternatives can help interpretation, but do not guarantee traffic or rankings. Ordinary img alt is also not a general mechanism for social link previews; social metadata and platform behavior are separate.

Test by reading the page without its images and by inspecting its accessibility tree. Learn img, figure, and a.

Sources

Reference 1 Reference 2 Reference 3 provide the technical details and current compatibility information.