After this lesson you can mark up any image so it is useful to a person who cannot see it and understandable to a search engine, and you can avoid the common ways images slow a page down. Alt text is both an accessibility duty and an SEO opportunity, and doing it well is mostly just describing things honestly.
What alt text is for
The alt attribute holds a short text alternative. A screen reader reads it aloud. A browser shows it if the image fails to load. A search engine uses it to understand the picture, especially together with the text around it. Google's guidance on image search calls alt text the most important piece of image metadata.
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='160'%3E%3Crect width='320' height='160' fill='%23e9c46a'/%3E%3C/svg%3E" width="320" height="160"
alt="A round sourdough loaf with a dark crust cooling on a wire rack">The alt text describes what the image shows and why it is on the page, in a natural sentence.
How to write it
- Describe it as you would to someone on the phone. Keep it specific. "Dalmatian puppy catching a ball" is more useful than "dog".
- Mind the context. The same picture of a loaf could have alt text about the baking stage on a recipe page, or about a product on a shop page.
- Keep it reasonably short. A sentence or two. If an image needs a long explanation, such as a chart, put the details in the visible text and give the alt a short summary.
- Do not start with "image of" or "picture of". Screen readers already say it is an image.
- Do not stuff keywords. Google's guidance warns against it, and it would sound ridiculous read aloud.
- Decorative images: use an empty
alt=""so assistive technology skips them. Do not omit the attribute; a missing one may be read as the file name. - Images that are links: the alt text should say where the link goes, for example "Crumb & Co. home".
This site's own content checker refuses a lesson containing an image without alt text, which is the same rule applied at build time.
File names
Short, descriptive file names help. Google's documentation gives the pattern: my-new-black-kitten.jpg rather than IMG00023.JPG. Use lowercase words separated by hyphens, and keep names stable once published, because changing the address of an image is like changing any URL.
Good: sourdough-loaf-cooling.webp
Poor: IMG_2041.JPG
Poor: final_FINAL_v3 (copy).pngUse real img elements
Google says it finds images through <img> elements with a src. Images that only exist as CSS backgrounds are not indexed. That is fine for decoration and a problem for anything you want found, such as product photos. When you need responsive sizes, srcset or the picture element are supported, with a normal img and src as the fallback.
Formats
Google Search supports BMP, GIF, JPEG, PNG, WebP, SVG and AVIF in img elements. Match the extension to the actual format. As a general practice: JPEG or WebP for photos, PNG for sharp graphics with transparency, SVG for logos and icons. Prefer modern formats if your audience's browsers support them, with a fallback when needed.
Size and speed
An oversized image is one of the most frequent causes of a slow page. Resize to the largest display size you need, compress, and set width and height so the browser reserves space and the layout does not jump. Lazy-load images below the first screen, but not your main hero image. See Core Web Vitals and page speed. The image compressor is a quick way to see how much a file shrinks.
Image sitemaps and captions
If images matter, such as a photography business, an image sitemap can help discovery, and Google says it can include images hosted on other domains. Captions, nearby headings and surrounding text also give context. A caption is read by people, so it is often a better place to put extra detail than alt.
Original images
Using your own photos shows first-hand experience, a point from helpful content and E-E-A-T. Where you use stock images, nothing is wrong, but they add little that a thousand other pages do not. Check licences for any image you did not make.
Common mistakes
- Empty or missing alt on informative images.
- File names that are camera numbers.
- Alt text stuffed with keywords.
- Putting text inside an image with no text alternative, so it is invisible to search and screen readers.
- Uploading a 6 MB photo for a 400 pixel slot.
- Using CSS backgrounds for images that should be found.
Exercise
For the three images below, write alt text and a file name: (1) a photo of a baker shaping dough, (2) a decorative wavy line between sections, (3) the shop's logo that links to the home page.
Show a sample answer
(1) alt "A baker shaping sourdough dough on a floured bench", file baker-shaping-dough.webp. (2) alt "" (empty), as it carries no information. (3) alt "Crumb & Co. home", file crumb-and-co-logo.svg. Notice the logo's alt describes the destination, because it is a link.
Key points
- Alt text describes an image for people who cannot see it and helps search engines understand it; it is the most important image metadata, per Google.
- Use real img elements; Google does not index CSS background images.
- Use short descriptive file names, supported formats (including JPEG, PNG, WebP, AVIF, SVG) and right-sized files.
- Decorative images get an empty alt so assistive technology skips them.