Skip to content
Loremly
Guide

How to Write Good Alt Text for Images

Learn what alt text is, how to write short and useful descriptions, when to leave alt empty, and how to handle alt text for placeholder images.

Loremly Team

· 4 min read

Alt text is a short written description of an image. Good alt text says what matters about the image in that spot, in as few words as possible. If the image is only decoration, the alt text should be empty.

What alt text is

Alt text lives in the alt attribute of an HTML image tag. An attribute is a small piece of extra information you add to a tag. It looks like this:

<img src="dog-park.jpg" alt="A golden retriever catching a ball in a park">

Alt text does three jobs:

  • Screen readers read it aloud. A screen reader is software that reads a page out loud for people who are blind or have low vision. When it reaches an image, it reads the alt text.
  • It shows when an image fails to load. If the file is missing or the connection is slow, the browser can show the alt text in its place.
  • It helps search engines understand images. Search engines can't always tell what's in a picture. Alt text gives them a clear clue.

The first job matters most. Write alt text for people, not for search engines.

How to write good alt text

There's no single perfect description. The right alt text depends on why the image is there. Ask yourself: "If I couldn't see this image, what would I need to know?"

Here are some simple rules:

  1. Describe what matters in context. A photo of a red jacket on a shop page should mention the color and style. The same photo on a blog about travel packing might only need "A red rain jacket folded in a suitcase."
  2. Keep it short. A common guideline is to stay under about 125 characters. One clear sentence or phrase is usually enough.
  3. Don't start with "image of" or "picture of". Screen readers already tell the listener it's an image. Just describe it.
  4. Include any text that's in the image. If a banner says "Summer sale, 30% off", put those words in the alt text.
  5. Skip details that don't help. You don't need to list every object in the photo. Focus on the point.
  6. Don't stuff in keywords. Repeating search terms makes alt text harder to listen to and doesn't help readers.

Good vs bad examples

Image Bad alt text Better alt text
Team photo on an About page "image of people" "Our five-person support team standing outside the office"
Product photo in a shop "shoe.jpg" "White canvas sneaker with a gum rubber sole, side view"
Chart in a report "chart" "Bar chart showing sales rising each quarter, highest in Q4"
Banner with a message "banner" "Free shipping on all orders this weekend"
Company logo in the header "logo" "Loremly"
Search button with a magnifying glass icon "magnifying glass" "Search"

Notice the last two. When an image is a link or a button, describe what it does, not what it looks like. A logo that links home is usually best described by the company name.

For complex images like detailed charts, keep the alt text short and put the full details in the text on the page, such as a caption or a table.

Decorative images get empty alt

Some images add style but no information. Think of background patterns, divider lines or a stock photo that just adds mood. For these, use an empty alt attribute:

<img src="wave-divider.png" alt="">

This tells screen readers to skip the image. Without it, some screen readers will read the file name instead, which is just noise.

Two common mistakes to avoid:

  • Leaving out the alt attribute entirely. Always include it, even if it's empty.
  • Writing "decorative" as the alt text. That gets read aloud. Use alt="" instead.

If an image sits right next to text that already describes it, empty alt can also make sense. There's no need to say the same thing twice.

Alt text for placeholder images

While you build a site, you'll often use placeholder images before the real photos arrive. Loremly's placeholder image generator makes photos, illustrations and solid-color images at any size you need.

Here's a simple way to handle alt text for them:

  • Purely decorative placeholders can use alt="" from the start. If the final image will also be decorative, nothing needs to change later.
  • Placeholders for real content need proper alt text once the final image goes in. Don't describe the placeholder itself, because "Random photo of a forest" won't make sense next to the real product shot.

A good habit is to leave a note in your code where real alt text is still needed:

<!-- TODO: write alt text when the final product photo is added -->
<img src="https://www.loremly.com/api/v1/photo?w=600&h=400&seed=product-1" alt="" width="600" height="400">

Before launch, search for those notes and fill them in. That way no real content image goes live without a description. Our guide to placeholder images has more tips for working with them.

A quick test before you publish

Read your page out loud, and read each alt text in place of its image. Ask yourself:

  • Does each description make sense in that spot?
  • Is anything important missing?
  • Is anything repeated or too long?
  • Are decorative images using alt=""?

If the page still makes sense when you can't see the pictures, your alt text is doing its job.

Share

Written by

Loremly Team

We build Loremly, the free Lorem Ipsum and placeholder image generator, and write about design and development workflows.

All posts