Area alt attribute

Definition and usage

Alt Attribute to set or return the area Alt attribute The value.

If the image cannot be displayed, the alt attribute specifies the alternative text for the area.

Example

Example 1

Get the alternative text for a specific area in the image map:

var x = document.getElementById("venus").alt;

Try it yourself

Example 2

Change the alternative text for a specific area in the image map:

document.getElementById("venus").alt = "The planet Venus";

Try it yourself

Syntax

Return the alt attribute:

areaObject.alt

Set the alt attribute:

areaObject.alt = text

Attribute Value

Value Description
text The alternative text for the area.

Technical Details

Return Value: A string value representing the alternative text for the area.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:The alt attribute of HTML <area>