HTML - <map> Tag



HTML <map> tag is used to define an image map to make clickable area on the image. This is an excellent assistance for enhancing the interactivity of websites.

If we want to make the graphics more interactive we can use image mapping.Wwe can navigate between images within the same frame and interact with the image. When we wish to accomplish a feature like zooming in on the website's image, this feature is helpful. There will be a clickable area on each image, and we can set the URLs or other images to redirect when the user clicks on that area.

Syntax

<map name="">...</map>

Attribute

HTML map tag supports Global and Event attributes of HTML. And a specific attribute as well which is listed bellow.

Attribute Value Description
name mapname Defines a unique name for the map tag.

An image map is defined by the combination of the HTML <area> and <map> tags. An image map consists of an image with clickable portions; by clicking the image, a new window or the specified location will open. The <area> element, which specifies the location and type of the area, may contain more than one instance. Without separating the image, you may quickly link any portion of image to other documents using the <map> element.

Examples of HTML map Tag

Bellow examples will illustrate the usage of map tag. Where, when and how to use map tag and how we can manupulate map element using CSS.

Maping on an Image

Let’s look at the following example, where we are going to use the <map> tag and navigate to another page by specifying the link.

<!DOCTYPE html>
<html>
   <body>
   <h3>HTML map Tag</h3>
   <img src="https://www.tutorialspoint.com/cg/images/logo.png"
        alt="Workplace"
        usemap="#workmap"
        width="400"
        height="70">
   <map name="workmap">
      <area shape="rectangle" 
            coords="33,45,271,300"
            alt="tutorial" 
            href="https://www.tutorialspoint.com/index.htm">
   </map>
</body>
</html>

Navigating Images with the map Tag

Consider another scenario where we are going to use the <map> tag to navigate to another image within the same frame.

<!DOCTYPE html>
<html>
<body>
   <center>
      <p>Click on Images where the cursor clickable.
      </p>
      <img src="https://www.tutorialspoint.com/cg/images/logo.png"
           alt="logo" usemap="#tutorial">
      <map name="tutorial">
         <area shape="rect"
         coords="0, 0, 52, 52"
         alt="tutorial"
         href="https://www.tutorialspoint.com/html/images/html.jpg">
      </map>
   </center>
</body>
</html>

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
map Yes Yes Yes Yes Yes
html_tags_reference.htm
Advertisements