alt (HTML attribute)

Depr. Version
Browser support (more…)
IE5.5+ FF1+ SA4 OP9.2+ CH2
Full Full None Full None




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).

Figure 1. The alternative text showing for a missing image submit button Missing image submit button showing the alternative text

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).


This code shows the alt attribute for a form’s image submit input:

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


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).


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.

Related Products