Language References
Provides alternative or fallback text for a graphic.
Inline |
<element alt = strText...> |
Script |
object.alt = strText |
strText |
String specifying the text to display as an alternative to the graphic. |
The property is read/write with no default value.
Several non-textual elements ( AREA, IMG, INPUT type=image ) let authors specify alternate text to serve as content when the element cannot render normally.
This may happen because the image is no longer available at the specified location, or the user has disabled the loading of images.
But perhaps the most important reason to use the alt property is to support accessibility.
Specifying alternate text assists users without graphic display terminals, users whose browsers do not support forms, visually impaired users, those who use speech synthesizers, those who have configured their graphical user agents not to display images, etc.
The alt attribute must be specified for the <img
> and <area
> elements; it is optional for the <input type=image
> element.
For <img
> tags, authors should specify only relevant and meaningful alternate text appropriate for the image.
For <area
> tags, authors should define textual labels for an image map’s hyperlinks.
Note that the alternate text will only display in certain cases. If you want to provide information construed as a caption or title along with the image, such as when the mouse is over the image, use the title attribute instead.
Browsers differ in how they handle cases of omitted alternate text.
The below shows a simple scenario showing the alt attribute text when the specified image source is not available.
<img src=/images/artist.gif alt="Your alt text here">
AREA IMG INPUT TYPE=IMAGE