Alternative text helps users understand non-text content when it cannot be seen.
Depending on the element, this alternative can be provided with alt, aria-label, aria-labelledby,
title or fallback content. For <svg> elements, the accessible name comes from aria-labelledby,
aria-label or a direct <title> child, in that order of precedence; alt has no effect on
<svg>.
It is used whenever the actual image or embedded content cannot be rendered.
Common reasons for that include:
It is also very important not to set an alternative text to a non-informative value. For example, <img … alt="logo"> is useless
as it doesn’t give any information to the user. In this case, as for any other decorative image, it is better to use a CSS background image instead of
an <img> tag. If using CSS background-image is not possible, an empty alt="" is tolerated. See Exceptions
below.
This rule raises an issue when:
<img> element has no alt attribute and no non-empty aria-label or aria-labelledby
attribute.<input type="image"> element has no non-empty alt, aria-label or aria-labelledby
attribute.<area> element within an image map has no non-empty alt, aria-label or
aria-labelledby attribute.<object> element has no non-empty inner text, accessible descendant content, title, aria-label
or aria-labelledby attribute.<svg> element conveying information has no non-empty aria-labelledby, aria-label or direct
<title> child.<img> elements with an empty string alt="" attribute won’t raise any issue. However, this way should be used
in two cases only:
When the image is decorative and it is not possible to use a CSS background image. For example, when the decorative <img> is
generated via javascript with a source image coming from a database, it is better to use an <img alt=""> tag rather than generate
CSS code.
<li *ngFor="let image of images">
<img [src]="image" alt="">
</li>
When the image is not decorative but its alt text would repeat a nearby text. For example, images contained in links should not
duplicate the link’s text in their alt attribute, as it would make the screen reader repeat the text twice.
<a href="flowers.html">
<img src="tulip.gif" alt="" />
A blooming tulip
</a>
In all other cases you should use CSS background images.
<svg> elements won’t raise any issue when they are hidden from assistive technology, for example through their own or an
inherited aria-hidden="true" or hidden attribute, or when they carry decorative semantics, for example
role="none" or role="presentation".
<svg aria-hidden="true" viewBox="0 0 24 24"> <path d="M12 4v16" /> </svg> <svg hidden viewBox="0 0 24 24"> <path d="M12 4v16" /> </svg> <svg role="presentation" viewBox="0 0 24 24"> <path d="M12 4v16" /> </svg>
Provide alternative text using the attribute or content expected by the element. Prefer alt for <img> elements. For
<svg> elements, use aria-label, aria-labelledby or a direct <title> child instead, as
alt has no effect there.
<img src="foo.png" /> <!-- missing `alt` attribute -->
<img src="foo.png" aria-label="" /> <!-- empty accessible name -->
<input type="image" src="bar.png" /> <!-- missing alternative text -->
<input type="image" src="bar.png" alt="" /> <!-- empty alternative text on <input> -->
<img src="house.gif" usemap="#map1"
alt="rooms of the house." />
<map id="map1" name="map1">
<area shape="rect" coords="0,0,42,42"
href="bedroom.html"/> <!-- missing alternative text -->
<area shape="rect" coords="0,0,21,21"
href="lounge.html" aria-labelledby=""/> <!-- empty accessible name on <area> -->
</map>
<object></object> <!-- missing alternative text -->
<object title=" "></object> <!-- empty alternative text -->
<svg viewBox="0 0 24 24"> <!-- missing accessible name -->
<path d="M12 4v16" />
</svg>
<svg aria-label="" viewBox="0 0 24 24"> <!-- empty accessible name -->
<path d="M12 4v16" />
</svg>
<img src="foo.png" alt="Some textual description of foo.png" />
<img src="logo.png" aria-label="Company logo" />
<span id="bar-label">Textual description of bar.png</span>
<input type="image" src="bar.png" aria-labelledby="bar-label" />
<img src="house.gif" usemap="#map1"
alt="rooms of the house." />
<map id="map1" name="map1">
<area shape="rect" coords="0,0,42,42"
href="bedroom.html" alt="Bedroom" />
<area shape="rect" coords="0,0,21,21"
href="lounge.html" aria-label="Lounge"/>
</map>
<object title="Sales chart"></object>
<object>
Quarterly sales for 2026
</object>
<svg viewBox="0 0 24 24">
<title>Arrow Down</title>
<path d="M12 4v16" />
</svg>
<svg aria-label="Arrow Down" viewBox="0 0 24 24">
<path d="M12 4v16" />
</svg>