On this page
Graphical user interface displaying the letters H, T, M, and L and the attribute ALT

Everything you need to know about the alt attribute

Discover everything about the alt attribute, its importance for SEO, accessibility, and how it enhances the user experience on websites.

The alt attribute is still mostly missing, misused, or misunderstood.

So, what is the alt attribute for? What is the use of alt? And why using it correctly is so important.

What is the alt attribute?

The alt attribute in HTML stands for alternative text. It is used in HTML documents to specify alternative text that is to be displayed in place of the element that cannot be rendered. Primarily used with the img (image) element and input type image.

But the alt attribute is not only about screen readers. It is one of the simplest and most powerful ways to expose information about images to machines-search engines, indexers, text-only browsers, automated audit tools, and machine learning models. Even when an image is not critical to the human-facing content, its alt text can still be very valuable for processing, discovery, and reuse of information across the web.

The alt attribute examples

Image Map (with clickable areas)
<img src="path/to/world-map-image.jpg" width="600" height="600" alt="World Map" usemap="#worldMap">
<map name="worldMap">
<area shape="rect" coords="0,0,50,50" href="#" alt="Asia" title="Asia">
<area shape="rect" coords="60,10,110,60" href="#" alt="Africa" title="Africa">
<area shape="rect" coords="120,30,170,80" href="#" alt="North America" title="North America">
<area shape="rect" coords="130,90,180,140" href="#" alt="South America" title="South America">
<area shape="rect" coords="20,150,70,190" href="#" alt="Antarctica" title="Antarctica">
<area shape="rect" coords="80,40,130,90" href="#" alt="Europe" title="Europe">
<area shape="rect" coords="160,120,210,170" href="#" alt="Australia/Oceania" title="Australia/Oceania">
</map>
The alt attribute in image tag​
<img src="https://example.com/images/cat.jpg" alt="A cute cat sitting on a window sill" width="300" height="200">
HTML form with image submit button
<form action="/submit_form" method="post">
<div><label for="name">Name</label><input type="text" id="name" name="name"></div>
<div><label for="email">Email</label><input type="email" id="email" name="email"></div>

<div><input type="image" src="submit-button.png" alt="Submit Button" width="100" height="40"></div>
</form>

The alt attribute vs property

The alt attribute and the alt property are both used within HTML to provide alternative text for images, but they serve slightly different purposes and have nuances that are important to understand.

Attributes are defined by HTML. Properties are defined by the DOM (Document Object Model).

Properties reflect the live state of elements, whereas attributes represent the initial state when rendered in the DOM.

Key differences:

  • Definition: the alt attribute is written in the HTML code of an image element, e.g., <img src="example.png" alt="Description of the image">. The alt property can be accessed or modified using JavaScript, e.g. document.querySelector("#exampleImage")?.alt = "New description".

  • Synchronization: changes to the alt property in the DOM do not automatically update the alt attribute in the HTML. This means that the initial value set in HTML can differ from what is currently in the DOM if modified by JavaScript. However, you can use methods setAttribute and removeAttribute to update the attribute in the DOM. These methods are part of the HTMLElement interface and allow you to dynamically modify the attributes of an element.

    When you use setAttribute, it sets or changes the value of an attribute on the specified element. If the attribute already exists, its value is updated. If it does not exist, the attribute is added.

    The removeAttribute method, on the other hand, removes the specified attribute from the element.

Chrome browser developer tools, tab Elements, section Properties
Chrome browser developer tools, tab Elements, section Properties

Read article View the properties of DOM objects to find out how to access and manipulate element properties using Chrome DevTools.

Accessibility

The primary function of the alt attribute is to enhance accessibility for visually impaired users. The text alternative can be read aloud or rendered as Braille. Screen readers read the alt text aloud, allowing these users to understand the content and purpose of images on a webpage.

For example, if an image of a dog is described with the alt text “a small dog sitting on a windowsill”, the screen reader will convey this information to the user, making the web content more inclusive.

For input elements of type image, the alt attribute of the input element is used to provide a functional label. This label indicates the button’s purpose but makes no attempt to explain the image.

The alt attribute is required for WCAG 2.1 Success Criterion 1.1.1 (Non-text Content) at Level A. This means that failing to provide appropriate alt text is a violation of accessibility standards.

In many jurisdictions, websites must comply with accessibility laws:

Missing or incorrect alt text has led to lawsuits against major companies including Domino’s, Beyoncé, and Harvard.

SEO (Search Engine Optimization) and the alt attribute

Search engines can’t directly interpret images the way humans do, so they rely heavily on alt text to understand image content. While Google’s AI (including multimodal models like Gemini) has improved image understanding, alt text remains a critical ranking signal, especially for image search.

Descriptive alt attributes help search engines accurately index images, improving your chances of appearing in relevant search results, especially in image searches. Image search in search engines refers to the functionality that allows users to find images on the internet based on specific keywords or phrases. This feature is provided by most major search engines. It enables users to input text queries related to what they’re looking for, and the search engine then returns relevant images from across the web.

Remember, the search engine doesn’t see like we do. It interprets the code. The better the image description, the better the chance for a better position in search results.

Even if an image is not a critical part of the visible content (for example, a portrait of the author, a logo of a partner, or a thumbnail in a listing), a meaningful alt attribute still helps machines understand what is there, connect it to entities, and surface it in search or other automated contexts. From the perspective of the web as an information network, omitting alt is often a lost opportunity.

SEO best practices for alt text

  • Keep alt text under 125 characters (screen readers often cut off longer text).
  • Include relevant keywords naturally. Do not keyword stuff.
  • Do not start alt text with Image of or Picture of because screen readers already announce it as an image
  • Be specific and contextual – the same image may need different alt text on different pages

Backup content when image fails to load

If an image fails to load, the alt text serves as a backup description, appearing as text in place of the broken image icon.

Alt text during the image loading

Some browsers may display alt text during the loading process, especially if the image takes time to load. This can vary between browsers and versions.

The alt for text-only browsers

A text-only browser is a type of web browser that displays only the textual content of web pages, excluding most graphic content such as images, videos, and animations. This type of browser is very useful in low-bandwidth environments since it loads sites faster than graphical web browsers.

Text-only browsers, such as Lynx, do not support the display of images in the same way that graphical browsers do. Instead, they provide an alternative method to convey the information that images would typically represent.

When a text-only browser encounters an image, it will display the text specified in the alt attribute of the img tag. This allows users to understand what the image represents without seeing it visually.

If an image with the alt attribute reads A beautiful sunrise, a text-only browser would display:

[A beautiful sunrise]

Some examples of text-based web browsers include Lynx, Links, ELinks, w3m, and Browsh. These browsers vary in features but share the common characteristic of focusing on text content over graphical elements.

Decorative images

Decorative images are those that serve only to enhance the visual appeal of a webpage without adding informational value. Examples include background images, divider lines, or images used solely for aesthetic purposes. Since these images do not need to be described to make sense of the content, they should have an empty alt attribute to avoid unnecessary noise for assistive technologies.

Critical distinction: alt="" vs missing alt attribute

  • <img src="decorative.png" alt=""> – correct for decorative images. Screen readers skip the image entirely.
  • <img src="decorative.png"> – wrong! Missing alt attribute causes screen readers to announce the image filename (e.g., decorative.png image), creating noise.
  • <img src="decorative.png" alt="decorative image"> – wrong! Unnecessary text that adds no value.

Always use alt="" for purely decorative images. Never omit the alt attribute entirely.

However, there is an important nuance: alt="" itself is not semantically rich. A machine, a screen reader, or an automated audit tool cannot tell whether the author intentionally marked the image as decorative or simply forgot to provide a description. From the perspective of semantics, alt only tells us whether there is text or not-it does not express the author’s intent.

To make that intent clearer, you can combine alt="" with other attributes such as role="presentation" or aria-hidden="true" on purely decorative images. This gives assistive technologies and automated tools a stronger signal that the image is intentionally non-informational:

Example: decorative image with explicit intent
<img src="divider.png" alt="" role="presentation" aria-hidden="true">

Complex images (infographics, charts, diagrams)

The alt attribute has a practical limit of around 125 characters. For complex images like infographics, charts, or diagrams, the alt attribute alone is insufficient.

Best practices for complex images

  • Use a short alt text identifying the image type and topic (e.g., alt="Bar chart showing website traffic growth from 2020 to 2026")
  • Provide a full text alternative elsewhere using:
    • The longdesc attribute (limited support).
    • A visible text description near the image.
    • An accessible table for data charts.
    • The figure and figcaption elements with detailed description.
    • aria-describedby linking to a description elsewhere on the page.
Example: complex image with extended description
<figure>
<img src="sales-chart.png" alt="Sales growth chart 2023-2025" aria-describedby="chart-description">
<figcaption id="chart-description">Sales increased from €50,000 in Q1 2023 to €120,000 in Q4 2024, with a slight dip in Q2 2024. Projected sales for Q1 2025 are €135,000.</figcaption>
</figure>

The alt attribute generator

The alt attribute generator also refers to the image description generator. We have used the Pallyy Image Description Generator designed to assist users in generating compelling descriptions for images.

This tool leverages artificial intelligence (AI) to analyze uploaded images and produce high-quality, descriptive captions that can enhance the effectiveness of social media posts, blog entries, product listings, and other forms of digital content.

Caution about AI alt text generators: While AI tools can provide good starting points, they often miss contextual relevance, cultural nuances, and the specific purpose of the image on YOUR page. Always review and edit AI-generated alt text. The alt text should serve the content’s purpose, not just describe visual elements.

Alt as a semantic interface (and its limitations)

The alt attribute often gets treated as a purely accessibility feature, but in practice it is a broader semantic interface between your content and all the technologies that consume it: assistive technologies, search engines, text-only browsers, automated audit tools, and machine learning models.

At the same time, alt is semantically limited. It tells us what text to use instead of the image, but it does not tell us why the image is there, what role it plays, or whether the absence of text is intentional. alt="" does not distinguish between “this is decorative” and “the author forgot to add a description”.

Because of that, good practice today is to treat alt as one part of a richer semantic strategy:

  • Use meaningful alt text whenever the image conveys information or represents something identifiable (person, product, place, logo, etc.), even if the page content does not strictly depend on it.
  • Use alt="" only for images that are truly decorative, and consider adding role="presentation" or aria-hidden="true" to make the intent explicit. Also, adding role="presentation" or aria-hidden="true" also helps automated audits determine the decorative state with 100% certainty, because these attributes explicitly communicate author intent beyond what alt="" alone can express.
  • For complex or critical images, combine alt with figure, figcaption, aria-describedby, or other structures that expose full semantics.

Quick reference: when to use what

Image typeCorrect alt attributeExample
Informative photoDescriptive, concise textalt="A golden retriever puppy playing in autumn leaves"
DecorativeEmpty string + optional explicit intentalt="" role="presentation" aria-hidden="true"
Logo (with link)Brand name or destination descriptionalt="Apple homepage"
Button (input image)Action descriptionalt="Search" or alt="Submit payment"
Complex chart/graphBrief identification + separate detailed descriptionalt="Quarterly revenue chart" + aria-describedby
Image of textThe exact text (avoid when possible)alt="50% off all items"
Author/portrait imagePerson’s name or rolealt="Jane Doe, accessibility specialist"
Partner/logo in listingEntity namealt="City of Toronto"

Common mistakes to avoid

  • Keyword stuffing: alt="dog puppy dog food pet supply buy dog online best dog" – this looks like spam to search engines and is annoying to screen reader users.
  • Redundant phrases: alt="Image of a cat" – screen readers already announce image.
  • Filename as alt text: alt="img_54321.jpg" – completely useless.
  • Overly long alt text: 125+ characters – screen readers may cut off.
  • Missing alt on functional images: links or buttons with images but no alt text – screen reader users won’t know the destination or action.
  • Assuming alt is only for accessibility: ignoring its role in SEO, indexing, and machine processing.
  • Using alt="" without intent: marking non-decorative images as empty alt, losing information for both users and machines.

Testing your alt attributes

You can test the effectiveness of your alt text using:

Final words

When you review your images, don’t just ask is this accessible?, but also ask does this image carry information that could be useful to machines or to users searching for it later?.

The alt attribute is a small piece of code, but it sits at the intersection of accessibility, semantics, SEO, and the broader information architecture of the web.

Related posts

Comments

Leave a Reply

Search in sitelint.com

Elevate your website’s accessibility with SiteLint

Your reliable source for inclusive online experiences. Our cutting-edge tools and services enable businesses to create user-friendly web environments. Join the digital inclusivity movement to discover new ways to engage and grow. Discover the SiteLint platform today and transform your online presence into a beacon of accessibility.