Skip to: content, navigation

by Ian Lloyd

alt (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf3 Op9.2+
Full Full None Full
Spec
Depr. Version
No HTML 2
alt="alternative text for image"

Example

The alt attribute for a form’s image submit input:

<form>
…
<input type="image" src="submit.jpg"
alt="Submit your details" />
</form>

Description

In the event that the user cannot view the image - perhaps because of a very slow connection, an incorrect src attribute, or even because the user is blind and is accessing the content using a screen reader - the alt attribute provides an alternative to the image that can be used instead. If the image is missing, the browser can display the alternative an example of which is shown in #alt/fig-submit-image-missing (screenshot taken from IE6 on Windows XP).

Figure 1. Missing image submit button showing the alternative text Missing image submit button showing the alternative text

The 'alt' attribute should be considered required when the type attribute is set to "image", although that requirement cannot be expressed in an SGML DTD (hence the chart does not show this as a required attribute - because it depends on context).

Value

Text that is equivalent to the content of the image - should state clearly what pressing the button/image will do.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3None
2.0None
3.0None
Opera9.2Full
9.5Full

Generally good support, but Safari lets the side down by not displaying suitable alternative content when the image does not load (it simply displays a rather unhelpful question mark).

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters