HTML - usemap Attribute
HTML usemap attribute creates relationships between <img> and <map> by specifying an image or an object with clickable areas.
The usemap attribute is associated with a <map> elements name or id attribute and creates a relationship between the <img> and the <map>.
Syntax
<tag usemap-"#mapname">
The "mapname" is used to hold the map name containing the hash (#) character.
Applies on
The below-listed elements allow the use of the HTML usemap attribute.
| Element | Description |
|---|---|
| <img> | HTML <img> tag is used to embed image into the HTML document. |
| <object> | HTML <object> tag in HTML is used to show multimedia on web pages, including audio, video, pictures, webisite, PDFs, and Flash. |
Examples of HTML usemap Attribute
Bellow examples will illustrate the HTML usemap attribute, where and how we should use this attribute!
Using usemap attribute on "img" Element
On running the below code, the output window will display the image on the webpage. when the user clicks on the respective areas of the image it further displays another image.
<!DOCTYPE html>
<html>
<body>
<h3>HTML usemap Attribute</h3>
<p>
Click on the computer, the phone, or the
cup of coffee to go to a new page and
read more about the topic
</p>
<img src=
"https://cdn.pixabay.com/photo/2017/11/27/21/31/computer-2982270_640.jpg"
alt="Workplace" usemap="#workmap" width="400" height="270">
<map name="workmap">
<area shape="rect" coords="100,50,200,250" alt="Computer"
href=
"https://images.unsplash.com/photo-1499951360447-b19be8fe80f5?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80">
<area shape="rect" coords="60,250,150,120" alt="Phone"
href=
"https://images.unsplash.com/photo-1511707171634-5f897ff02aa9?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8bW9iaWxlJTIwcGhvbmV8ZW58MHx8MHx8fDA%3D&w=1000&q=80">
<area shape="circle" coords="40,50,120" alt="Cup of coffee"
href=
"https://img.freepik.com/premium-photo/coffee-cup-old-wooden-table-with-cream_158502-63.jpg">
</map>
</body>
</html>
Using usemap attribute on "object" Element
When we run the below code, it will generate an output consisting of the image along with a text displayed on the webpage.
<!DOCTYPE html>
<html>
<body>
<h1>The object usemap attribute</h1>
<object data=
"https://img.freepik.com/free-vector/big-animals-set_1284-10911.jpg?w=2000"
width="250" height="200" usemap="#animalmap">
</object>
<map name="animalmap">
<area shape="rect" coords="30,10,100,100" alt="elephant"
href=
"https://media.istockphoto.com/id/479667835/photo/background-elephant.jpg?s=612x612&w=0&k=20&c=DwfinIerTq104FXWcBBwegTWcmw8tf18EGqa5IpEyFk=">
</map>
<p>
<b>Note:</b> The usemap attribute of the object element
is not supported in Chrome, Edge, Safari, and Opera.
</p>
</body>
</html>
Supported Browsers
| Attribute | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| usemap | Yes | Yes | Yes | Yes | Yes |




