Map name attribute

Definition and usage

name attribute sets or returns the name attribute value.

name attribute specifies the name of the image map.

The name attribute is associated with <img> of usemap attribute related, and create a relationship between the image and the map.

Note:When setting the name attribute, you should also set the usemap attribute of <img> - if not set, the relationship between the image and the map will no longer exist (the clickable area will no longer be clickable).

Note:In HTML5,<map> The id attribute of the element must be name attribute Have the same value (and cannot be null or empty).

Example

Example 1

Get the name of the image map:

var x = document.getElementById("planetmap").name;

Try it yourself

Example 2

Change the name of the image map:

document.getElementById("planetmap").name = "newMapName";

Try it yourself

Syntax

Return name attribute:

anchorObject.name

Set name attribute:

anchorObject.name = name

Attribute Value

Value Description
name Specifies the name of the image map.

Technical Details

Return Value: String value, representing the name of the image map.

Browser Support

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

Related Pages

HTML Reference Manual:HTML <map> name Atributo