Open In App

How to create an area inside an image-map using HTML?

Last Updated : 24 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

To define clickable regions within an image map in an HTML document, use the <area> tag. This tag directs users to different links when they click on specific areas of the mapped image. It is nested within the <map> tag as a child element. In HTML, <area> is self-closing.

Syntax:

<area> Contents </area> 

Example: The example below shows how to create an area inside an image-map using HTML5.

html
<!DOCTYPE html>
<html>

<body style="text-align: center">
	<h2>
		An area inside
		an image-map
	</h2>
	<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165729/area11.png" 
         alt="" width="300"
		 height="119" 
         class="aligncenter size-medium wp-image-910965" 
         usemap="#shapemap" />

	<map name="shapemap">

		<!-- Area tag contained image. -->
		<area shape="poly" coords="59, 31, 28, 83, 91, 83" href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165802/area2.png" 
              alt="Triangle">

		<area shape="circle" coords="155, 56, 26" href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165934/area3.png" 
              alt="Circle">

		<area shape="rect" coords="224, 30, 276, 82" href=
"https://media.geeksforgeeks.org/wp-content/uploads/20190227170021/area4.png" 
              alt="Square">
	</map>
</body>

</html>

Output:

mapimg


Next Article

Similar Reads