/ โ† Accessibility Fixes / Alt text length and icons
In this guide
  1. What alt text is for, and why length matters
  2. Deciding what each image needs
  3. Icons: silent, labelled or named on the control
  4. Worked examples for common images
  5. How to check alt text across a page
  6. Platform notes
  7. The fix, step by step
  8. Edge cases worth knowing
  9. Keeping alt text right
  10. Questions and answers

What alt text is for, and why length matters

The alt attribute on an <img> gives the image a text alternative. A screen reader reads it aloud when it reaches the image, a browser shows it in place of a broken image, and search engines use it, along with the surrounding text, to understand what the image shows. WCAG success criterion 1.1.1 (Non-text Content) asks that every image that carries meaning has a text alternative serving the same purpose, and that purely decorative images are marked so assistive technology can ignore them.

No standard sets a maximum length. HTML does not limit the attribute, and current screen readers read the whole value. The often-quoted figure of 125 characters is a working habit from older advice, not a rule. It is still a useful target, because alt text is heard in one go: a listener cannot skim it or jump back to the important part, and most screen readers do not let the user pause inside it as easily as inside normal text.

Image typeTypical alt lengthWhat it should say
Product or service photo5 to 15 wordsThe item and the detail that matters for choosing it
Logo linking to the home page2 to 5 wordsThe organisation name and home
Icon beside matching textEmptyNothing; the text already says it
Icon-only button or link1 to 4 wordsThe action or destination
Chart or diagramOne sentenceThe main finding, with the data in text nearby
Decorative flourish or dividerEmptyNothing

If your description needs more than about two sentences, the image probably holds information that belongs in the page itself, in a caption or in a paragraph that everyone can read.

Deciding what each image needs

The right alt text depends on what the image does in its place on the page, not on what the picture contains. The same photo of a red bicycle might need the model name on a shop page, the words Hire a bike on a button, and nothing at all as a background behind a heading. Work through these questions in order and stop at the first that fits:

  1. Is the image the only content of a link or button? Then the alt text is the name of that link or button. Describe the destination or action, such as Download the 2026 price list (PDF), not the picture.
  2. Does it contain text? If the text matters, repeat it in the alt. If the same words also appear as real text next to it, the image can be silent.
  3. Does it add information the page needs? Then describe that information briefly. For a chart, give the conclusion and put the figures in a table or paragraph.
  4. Is it purely decorative, or does it repeat nearby text? Then use alt="".

A helpful check is to imagine phoning a customer and reading the page to them. Whatever you would say when you reached the image is a good alt text. If you would say nothing, the alt should be empty.

Empty alt is not the same as missing alt

alt="" is a deliberate signal that the image is decorative. Screen readers skip it entirely. When the attribute is left out, many screen readers fall back to announcing the file name or the address, so a listener hears something like image, I M G underscore 2041 dot jpg. Audit tools flag missing alt for this reason. They should not flag a correctly empty alt, and if they do, the warning is a false positive rather than a reason to add a description.

โš ๏ธ Do not write alt=" " with a space. Some tools and screen readers treat a space as a non-empty value. Use two quotation marks with nothing between them.

Icons: silent, labelled or named on the control

Icons cause more confusion than any other image type because the same icon can need three different treatments. What matters is whether visible text already does the job.

Icon beside text that says the same thing

A phone icon next to the words Call us, a basket icon next to Basket, or a tick next to each item in a features list add nothing for a screen reader user. Hide them, otherwise the user hears phone, Call us or, worse, a file name before every list item.

<!-- Image file -->
<a href="tel:+441632960961"><img src="/icons/phone.svg" alt="" width="16" height="16"> Call us</a>

<!-- Inline SVG -->
<a href="/basket"><svg aria-hidden="true" focusable="false" width="16" height="16">...</svg> Basket</a>

<!-- Icon font -->
<button><i class="icon-print" aria-hidden="true"></i> Print</button>

Icon fonts deserve special care. The glyph is often a private-use character that some screen readers announce as an odd symbol or not at all, so always add aria-hidden="true" to the element that holds it.

Icon-only buttons and links

A magnifying glass that opens search, a cross that closes a dialog or a hamburger that opens the menu has no visible text, so the control needs an accessible name. Put the name on the control itself and hide the icon.

<!-- aria-label on the button -->
<button type="submit" aria-label="Search">
  <svg aria-hidden="true" focusable="false" width="20" height="20">...</svg>
</button>

<!-- Visually hidden text, which also translates with the page -->
<button type="button" class="menu-toggle">
  <svg aria-hidden="true" focusable="false">...</svg>
  <span class="visually-hidden">Open menu</span>
</button>

<!-- Image file inside a link: the alt is the link name -->
<a href="https://www.linkedin.com/company/example"><img src="/icons/linkedin.svg" alt="Our LinkedIn page"></a>

Visually hidden text uses the usual clip pattern, so it is read by assistive technology but takes up no space:

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
๐Ÿ’ก For a meaningful standalone SVG that is not inside a control, such as a status icon showing that an order has shipped, give it role="img" and an aria-label, or a <title> as its first child. Our ARIA labels guide covers the naming rules in more depth.

Worked examples for common images

These examples come from typical small business pages. Each shows the image, what it does on the page and the markup that fits.

ImageRole on the pageAlt text
Oak table on a product pageShows what is for saleOak dining table with six matching chairs
Company logo in the header, linking homeLink to the home pageAI Web Page SEO home
Same logo in the footer, not linkedBranding only, name in text beside itEmpty
Bar chart of yearly salesSupports a claim in the textBar chart: sales doubled from 2024 to 2026
Team photo on the About pageShows who the customer will meetThe four members of the support team outside the Leeds office
Abstract swirl behind a headingDecorationEmpty
Stock photo of a handshakeMood onlyEmpty
Scanned certificateProof of a qualificationGas Safe registration certificate, number 123456, valid to 2027

The chart deserves a closer look. The alt gives the one fact a listener needs to follow the argument. The detailed figures go in a short table or a paragraph under the chart, where everyone, including people who struggle to read small chart labels, can use them:

<figure>
  <img src="/images/sales-2024-2026.webp" width="800" height="450"
       alt="Bar chart: sales doubled from 2024 to 2026">
  <figcaption>Sales were 410 orders in 2024, 590 in 2025 and 830 in 2026.</figcaption>
</figure>

When a caption already describes the image fully, keep the alt short or empty so the listener does not hear the same sentence twice. More on images with visible captions is in the guide to alt text not showing on hover.

How to check alt text across a page

Automated tests can find missing alt attributes, but they cannot tell whether the text is right. Use a quick script to list every image and its alt, then judge each one with the questions above. Paste this into the browser console on any page:

console.table([...document.images].map(img => ({
  src: img.currentSrc.split('/').pop(),
  alt: img.hasAttribute('alt') ? img.alt : '(missing)',
  length: img.alt.length,
  inLink: !!img.closest('a, button'),
  hidden: img.closest('[aria-hidden="true"]') ? 'yes' : ''
})));

Look for four patterns in the table: (missing) values, which need fixing first; very long values over about 150 characters; values that are file names or start with Image of; and images inside links where the alt is empty, which leaves the link with no name at all.

For inline SVG and icon fonts, open DevTools, select the button or link, and read the Computed name in the Accessibility pane. If the name is empty, or reads as a stray symbol, the control needs a label. Lighthouse and similar checkers report this as buttons or links that do not have an accessible name.

Listen once

Turn on a screen reader for five minutes. NVDA is free on Windows, VoiceOver is built into macOS and iOS (Command and F5 on a Mac), and TalkBack is built into Android. Move through the page with the arrow keys or by swiping. You will quickly hear decorative images that should be silent and icon buttons that have no name. Our accessibility guide explains the wider checks worth running at the same time.

Platform notes

The fix, step by step

Step 1

List every image and its alt

Open the page, paste the console script from the audit section into DevTools and read the table it prints. Note each image with a missing alt, a file name as its alt, a value over about 150 characters, or an empty alt inside a link. Repeat for each page template, such as the home page, a product page, a blog post and the contact page. This list becomes your working checklist for the rest of the fix.

Step 2

Sort each image by its role

For every image on the list, decide its role: the only content of a link or button, an image containing text, an informative image, or decoration. Write the role next to it. Do not start writing descriptions until you have done this, because the role decides the answer. A logo can be a link to home on one page and pure branding on another, and a photo can be informative or purely mood-setting.

Step 3

Write short alt text for informative images

For product photos, team photos, certificates and similar images, write a phrase or sentence that gives the information the image adds to the page. Name the item and the detail that matters, and stop. Most will land between five and fifteen words. Do not begin with Image of or Picture of. Check each one by reading the surrounding paragraph aloud with the alt in place of the image and listening for gaps or repetition.

Step 4

Name linked images and icon-only controls

Where an image or icon is the only content of a link or button, set its name to the destination or action, such as Search, Close or Download the price list. Use alt on an image file, or aria-label or visually hidden text on the button for inline SVG and icon fonts. Then select the control in the DevTools Accessibility pane and confirm the Computed name shows the words you intended.

Step 5

Silence decorative images and duplicate icons

Set alt="" on decorative images, stock mood photos and icons that sit beside words saying the same thing. For inline SVG and icon fonts add aria-hidden="true", and focusable="false" on SVG for older browsers. Make sure the empty alt has no space inside it. Rerun the console script and confirm these images now show an empty value rather than missing, and that none of them is inside a link without other text.

Step 6

Handle charts and images of text

For charts and diagrams, write one sentence giving the main finding as the alt and put the figures in a caption, table or paragraph that everyone can read. For images containing words, such as promotional banners, copy the important words into the alt, or replace the image with real text over a background. Check the page by reading only the text and the alt values and confirming nothing essential is lost.

Step 7

Fix the source in your CMS or code

Make the changes where they will last. In WordPress edit the alt on each image block, not only in the media library. In Shopify update the media alt fields and check the theme fallback. In React or other component code, change the shared icon and image components so icons are hidden by default and require a label when used alone. Clear any page cache and reload the live page.

Step 8

Test with a screen reader and an audit

Run a Lighthouse accessibility audit and confirm there are no warnings for images without alt or buttons and links without names. Then turn on NVDA, VoiceOver or TalkBack and move through the page. You should hear clear names for every control, short descriptions for informative images, and nothing at all for decoration. Anything that sounds repeated or confusing goes back to the earlier steps for another pass.

Edge cases worth knowing

Keeping alt text right

  1. Write a one-page alt text rule for everyone who uploads images: describe the purpose, keep it short, leave decoration empty, and never use the file name.
  2. Build icons into components that hide them by default and require a label prop when the icon is used on its own. That way a developer cannot ship an unnamed icon button by accident.
  3. Run an automated accessibility check on each template after changes, and review new pages by reading the console table above.
  4. Recheck after theme or plugin updates, which often change how icons and logos are printed.

The broader rules on writing descriptions are in the alt text guide, and the treatment of purely visual images is covered in fixing decorative images.

Questions and answers

1. Is there a character limit for alt text?

No, there is no official character limit for alt text in HTML or in WCAG, and modern screen readers read the full value. The figure of 125 characters comes from older advice and works well as a habit rather than a rule. Short alt text is easier to listen to, because a screen reader user hears it in one go and cannot skim it. If you need more than a couple of sentences, put the detail in a caption or in the page text and keep the alt to the main point.

2. Do icons need alt text?

Icons need alt text only when they carry meaning that is not already in visible text. An icon beside a word that says the same thing, such as a phone icon beside Call us, should be hidden with an empty alt or aria-hidden so the screen reader does not repeat itself. An icon that is the only content of a button or link, such as a magnifying glass for search, needs an accessible name on that control, given through alt, aria-label or visually hidden text.

3. What is the difference between empty alt and no alt attribute?

An empty alt attribute tells assistive technology the image is decorative and should be skipped, while a missing alt attribute leaves the screen reader to guess. When alt is missing, many screen readers announce the file name or image address instead, which is confusing and sometimes long. Audit tools flag missing alt for this reason. An empty alt written as two quotation marks with nothing between them is a correct, deliberate choice for decoration and should not be treated as an error.

4. Should alt text include keywords for SEO?

Alt text should describe the image honestly, and a relevant keyword is fine only where it is the natural way to describe it. Google uses alt text along with the page content to understand images, so an accurate description helps image search. Lists of keywords, town names or services make the page tiresome for screen reader users, and Google's guidance warns against keyword stuffing in alt attributes. Write for the listener first; that is also what serves search engines best.

5. What alt text should a logo have?

A logo that links to the home page should have alt text that names the organisation and the destination, such as the business name followed by home. That alt becomes the name of the link, so a screen reader user knows where it goes. A logo that is not a link and sits beside the business name in text can have an empty alt, because the name is already there. Avoid writing the word logo unless the visual identity itself is the subject of the page.

6. How do I add alt text to an SVG icon?

An SVG image file in an img tag takes an alt attribute in the normal way. For inline SVG, add aria-hidden set to true when the icon is decorative or sits beside text. When the inline SVG carries meaning on its own, give it role set to img with an aria-label, or a title element as its first child. If the SVG is inside a button or link with no other text, put the label on the button or link instead and hide the SVG itself.

7. Do decorative images need alt text for accessibility audits?

Decorative images need an alt attribute, but its value should be empty, which passes accessibility audits. WCAG asks that decoration is implemented so assistive technology can ignore it, and an empty alt does exactly that. Adding a description just to clear a warning makes the page worse for screen reader users, who then hear pointless descriptions of dividers and background shapes. If an audit tool flags a correctly empty alt as a problem, treat it as a false positive rather than changing your markup.

Check every image and icon on your page

The accessibility audit lists images with missing alt text, links and buttons without an accessible name and icons that screen readers will announce, so you can fix each one in order.

Open Accessibility Fixes โ†’
๐Ÿ’ฌ Got a problem?
Related Guides: All Accessibility Fixes  ·  Alt Text Guide  ·  Decorative Images  ·  ARIA Labels  ·  Alt Text Not Showing on Hover  ·  Learning Hub

About aiwebpageseo

aiwebpageseo.com is a data-driven SEO and AEO (Answer Engine Optimisation) platform providing a free suite of technical SEO tools. Rather than relying on AI-theorised assumptions, the platform analyses live URL performance, delivering objective diagnostics, page speed metrics, CLS debugging, and site crawl data alongside actionable technical tutorials.