| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA4 | OP9.2+ | CH2 |
|---|---|---|---|---|
| Full | Full | None | Full | None |
Syntax
Description
In the event that the user
cannot view the image you’ve used—perhaps because he or she is using a
very slow connection, you’ve included an incorrect src
attribute, or because the user is visually impaired and is accessing the
content using a screen reader—the alt attribute
provides alternative information, as Figure 1 shows (that screenshot taken from
IE6 on Windows XP).
The alt attribute should be
considered to be required when the type attribute
is set to "image", although that requirement cannot be
expressed in an SGML DTD (hence, this isn’t shown as a required
attribute—it depends on context).
Example
This code shows the
alt attribute for a form’s image submit
input:
<form>
⋮
<input type="image" src="submit.jpg"
alt="Submit your details"/>
</form>
Value
The attribute value comprises text that’s equivalent to the content of the image. As such, the text should state clearly the effect of pressing the button (or image).
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | None | None | None | None | Full | Full | Full | None |
Generally, good
support is provided for alt, but Safari and Chrome
don’t display suitable alternative content when the image fails to load
(they simply display a rather unhelpful question mark or broken image
icon, respectively).
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.




