Writing Alt Text That Actually Helps
Alt text is not a caption, not a keyword list and not a file name. Learn the decision tree that tells you what to write, and when to write nothing at all.
- Concept
- The decision tree
- Is the image purely decorative?
- Does the image carry information?
- Is the image inside a link or a button?
- Is the image already described by adjacent text?
- Is it a photograph in an article?
- Length and style
- Example: the same image, four contexts
- Alt text and SEO
- Important rules
- Common mistakes
- Best practices
- Practice
-
HTML Basics
- What is HTML: The Structure Layer of Every Web Page
- HTML Document Structure: DOCTYPE, html, head and body
- Elements, Tags and Attributes: The Vocabulary of HTML
- HTML Comments: Notes That Ship With Your Code
- Block Level and Inline Elements
- Writing and Running Your First HTML Page
- How a Browser Turns Markup Into a Page
- Text and Formatting
- Links and Navigation
- Images and Media
- Lists
- Tables
-
Forms
- Form Structure: form, action and method
- Input Types: Text, Email, Number, Date and the Rest
- Labels: The Most Important Element in a Form
- Checkboxes, Radio Buttons and Grouping
- select, option, optgroup and datalist
- textarea, File Uploads and Hidden Fields
- Buttons: submit, reset and button
- Built In Form Validation
- GET or POST: What Happens When a Form Is Submitted
- Semantic HTML
- HTML5 Features
- Head and Metadata
- HTML with CSS
- HTML with JavaScript
- Accessibility
-
HTML SEO
- How Google Works: Crawling, Indexing and Ranking
- SEO Friendly HTML Structure
- Titles and Descriptions That Earn Clicks
- Headings and Content Structure for Search
- Internal Linking and Anchor Text
- robots.txt and XML Sitemaps
- Canonical URLs and Duplicate Content
- Structured Data and JSON-LD
- Image SEO
- Core Web Vitals and Mobile Friendliness
- DevTools and Debugging
- Editor Productivity
- HTML Best Practices
- HTML Projects
- Advanced Projects
- Practice and Exams
Concept
alt holds the text alternative for an image: what a reader gets instead of the picture when they cannot see it. That covers more people than most developers expect - screen reader users, readers on connections where images fail, people who have images switched off to save data, and search engines, which have no eyes at all.
The question to answer is not what is in this picture. It is what would I have written here if I could not use an image?
The decision tree
Is the image purely decorative?
A divider, a background flourish, an icon sitting next to text that already says the same thing. Write an empty alt:
<img src="/images/swirl.svg" alt="">
<p><img src="/icons/phone.svg" alt=""> +91 20 2600 1234</p>An empty alt is an instruction: skip this, it adds nothing. Leaving the attribute out entirely does the opposite - the screen reader falls back to announcing the file name, and swirl underscore final underscore two dot s v g is worse than silence.
Does the image carry information?
Describe the information, not the pixels.
<!-- weak -->
<img src="chart.png" alt="Chart">
<!-- also weak: describes the object, not the point -->
<img src="chart.png" alt="A bar chart with four blue bars">
<!-- useful -->
<img src="chart.png" alt="Bus ridership by year: 2023 lowest at 1.2 million, rising each year to 2.1 million in 2026">Is the image inside a link or a button?
Then the alt text is the link text, and it must describe the destination.
<a href="/"><img src="/logo.svg" alt="Riverside College home"></a>
<button type="submit"><img src="/icons/search.svg" alt="Search"></button>An empty alt here leaves a link with no accessible name, announced as link and nothing else. It is one of the most common serious accessibility failures on the web.
Is the image already described by adjacent text?
Do not repeat it. If the caption beneath says what the picture shows, an empty alt avoids hearing it twice.
<figure>
<img src="/images/press.jpg" alt="">
<figcaption>The hand press in the college museum, still holding set type.</figcaption>
</figure>Is it a photograph in an article?
Describe what a sighted reader would take from it, in one sentence.
<img src="/images/queue.jpg"
alt="A queue of about forty people outside the admissions office in the rain">Length and style
- Aim for one sentence. Around one hundred and twenty five characters is a common practical ceiling, because several screen readers cut off around there.
- Do not start with image of or picture of. The screen reader already announces that it is an image.
- End with a full stop. It gives the screen reader a natural pause.
- Write plain prose, not keywords.
- If the image genuinely needs a paragraph - a complex diagram, a data table rendered as a picture - put the long description in the page text or a linked page, and keep the alt short.
Example: the same image, four contexts
| Context | Good alt text |
|---|---|
| Article about the college building | The red brick facade of the main block, seen from the road |
| Article about a flood | Water reaching the first step of the main block entrance |
| Logo linking to the home page | Riverside College home |
| Decorative banner behind a heading | alt="" |
Same file, four alternatives. Alt text depends on why the image is there, which is why it can never be generated automatically with any confidence.
Alt text and SEO
Google uses alt text to understand and rank images, and image search sends real traffic. But the guidance from Google and from accessibility standards points in exactly the same direction: describe the image helpfully in natural language. Keyword stuffing - alt="buy shoes online cheap shoes best shoes india" - is treated as spam and is unusable when read aloud.
Write for the person listening. The search benefit follows.
Important rules
- Every
imgneeds analtattribute. The value may be empty; the attribute may not be missing. - An image inside a link must have alt text unless there is other text in the same link.
altis not a tooltip. Browsers do not show it on hover; that istitle.- A CSS background image has no alt at all, which is why anything meaningful must be a real
img. - Text inside an image must be repeated in the alt, in full.
Common mistakes
- Omitting the attribute for decorative images instead of writing
alt="". - Using the file name, or leaving in a camera name such as DSC_0431.
- Starting every alt with image of.
- Writing
alt="logo"on a logo that links to the home page. - Repeating the caption word for word in the alt.
- Stuffing keywords.
- Putting important text in an image with no alt, so the content simply does not exist for some readers.
Best practices
- Write the alt at the same moment you place the image, never as a cleanup task later.
- Ask what the image is doing on the page, then write that.
- For charts, state the trend or the finding, and put the full data in a table nearby.
- Test with a screen reader occasionally. Ten minutes changes how you write alt text permanently.
- Add an automated check that flags missing alt attributes in review.
Practice
- Write alt text for a photograph of a crowded railway platform in three different articles: one about overcrowding, one about a new station roof, one where it is a decorative header.
- Find a page where the logo links home. Is the alt text useful when read alone?
- Turn off images in your browser and read one of your own pages. What content vanished?
- Write alt text for a line chart in under one hundred and twenty five characters that still conveys the finding.