HTML Tag Reference - HTML tag <map>








This <map> element is used to specify the coordinates of an image map in the page. You must use this element in conjunction with the <img> element and the <area> element.

<img> defines where is the image. <area> defines what is the coordinates.

Browser compatibility

<map> Yes Yes Yes Yes Yes

What's new in HTML5

None.





Attribute

Attribute Value Description
name mapname Required. Set the name of an image-map

Global Attributes

The <map> tag supports the Global Attributes in HTML.

Event Attributes

The <map> tag supports the Event Attributes in HTML.

Default CSS Settings

map {
    display: inline;
}




Example

A demo showing how to use <map> tag.

<html>
<body>
     <img src="http://java2s.com/style/download.png" 
          alt="Demo image" 
          width=200 
          height=100 
          usemap="#myMap">
     <map name="myMap">
          <area shape="rect" 
                coords="0, 0, 100, 50" 
                href="http://www.w3c.com">
          <area shape="rect" 
                coords="100, 0, 200, 50"
                href="http://www.microsoft.com">
          <area shape="rect" 
                coords="0, 50, 100, 100" 
                href="http://www.msn.com">
          <area shape="rect" 
                coords="100, 50, 200, 100"
                href="http://www.yahoo.com">
     </map>
</body><!--from   ww w  .  j a va 2 s .co m-->
</html>

Click to view the demo