HTML <img> alt Attribute

The alt attribute on an <img> tag defines alternative text to display in case the image cannot be loaded.

Example

#

An alt attribute on an <img> element.
The image is loaded without error, therefore the alternative text does not display.

Van Gogh, Self-portrait
<img src="/img/html/vangogh.jpg" 
     alt="Van Gogh, Self-portrait">



In this example the image name has a typo is therefore not found.
The alt text displays next to a broken image icon.

Van Gogh, Self-portrait
<img src="/img/html/vangooi.jpg" 
     alt="Van Gogh, Self-portrait">

Using alt

The alt attribute specifies alternative text for an image.

This text will be displayed when the image is not found, or cannot be loaded.

Alternative text is also used by screen readers and SEO to describe the image.

Tip: Use the alt attribute on all your images.


Syntax

<img alt="text" />

Values

#

Value Description
text Alternative text for an image element.

Browser support

Here is when alt support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <img>
Guides