alt (HTML attribute)
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).
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
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | None | |
| Opera | 9.2 | Full |
| 9.5 | Full |
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.

