alt

Jump to: navigation, search

alt

This article is Almost Ready.


W3C Recommendation

Summary

The alt attribute is used as a textual representation for graphics and buttons in browsers that don't or can't render images, or when the resource is not found.


Applies to HTMLImageElement

The alt tag is required for images and image buttons. It should provide a concise label for the element it is being applied to, for the case that a user is visually disabled or is using browser that doesn't render images.

The alt tag text should be displayed in place of the image if the resource is not found.

For images, it should describe what the image represents. The contents of an alt tag should use general, non-visual language to accommodate non visual users. For example, a picture of a lake intended to evoke an emotion should have text more descriptive than "Lake" or "Clear, blue lake". "Breathtaking open lake" may be more appropriate.

If an image is not intended to be part of the content of the page, but instead is purely functional or aesthetic, the alt text can be an empty string. This case could apply for an image used as a border or spacing element.

Examples

This example uses the 'alt' attribute to indicate that the icon displayed denotes a read/write property.

HTML

<!doctype html>
<title>Image alt attribute usage</title>
<img src="http://example.com/path/to/no.jpg" alt="No image, so here is the alt text">



Compatibility

Desktop

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic Support Beta
1
3
3
0.8

Mobile

Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic Support 1
6
Beta
14
2
3
Beta
3

See also

External resources

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]