HTML <map> name Attribute

The name attribute on a <map> tag assigns a name to that map element. This name is used by the image to reference the map.

Example

#

A name attribute on a <map> element.
The name is used by the image to reference the image map.

Computer Computer Keyboard Mouse
<img src="/img/html/computer-map.png" alt="Computer" usemap="#computermap">

<map name="computermap">
  <area shape="rect" coords="253,142,16,2" alt="Computer" href="javascript:alert('Computer screen was clicked');">
  <area shape="rect" coords="262,218,0,156" alt="Keyboard" href="javascript:alert('Computer keyboard was clicked');">
  <area shape="circle" coords="267,234,22" alt="Mouse" href="javascript:alert('Computer mouse was clicked');">
</map>

Using name

The name attribute assigns a name to the image map.

This name helps establishing a relationship between the image and the image map.

The image uses the usemap attribute to reference the map's name.


Syntax

<map name="mapname">

Values

#

Value Description
mapname String value that is the name of the image map.

Browser support

Here is when name support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <map>
Guides