Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Image alt property

Image alt property

Image Object Reference Image Object


Definition and Usage

The alt property sets or returns the value of the alt attribute of an image.

The alt attribute specifies the replacement text displayed when the image cannot be displayed properly (slow network, broken image link).

Note: Internet Explorer displays tooltip text after the mouse moves over the img element, which is non-standard according to the HTML specification. All other browsers display the alt text only when the image cannot be shown.

Tip: If you want to create an image toolbar, use the title attribute.

Syntax

imageObject.alt=

text


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the alt property.


Example

Example

Return the replacement text of the image:

Runoob Tutorial(runoob.com) Crazy computerman

The alt attribute value is:

Try it »


Image Object Reference Image Object