Tag/AttributeValue
<img>Below are the image map-specific attributes to use with <img>. Regular <img> attributes apply.
usemapThe name of the map with a hash symbol prepended to it. For example, for a map with name=“map”, the image should have usemap=“#map”.
<map>
nameThe name of the map to identify it. To be used with the image’s usemap attribute.
<area>Below are <area>-specific attributes. When href is specified, making the <area> a link, <area>
also supports all of the attributes of the anchor tag (<a>) except ping. See them at the MDN docs.
altThe alternate text to display if images are not supported. This is only necessary if href is also set on the <area>.
coordsThe coordinates outlining the selectable area. When shape=“polygon”, this should be set to a list of
“x, y” pairs separated by commas (i.e., shape=“polygon” coords=“x1, y1, x2, y2, x3, y3, …”).
When shape=”rectangle”, this should be set to left, top, right, bottom. When
shape=“circle”, this should be set to centerX, centerY, radius.
hrefThe URL of the hyperlink, if specified. If it is omitted, then the <area> will not represent a hyperlink.
shapeThe shape of the <area>. Can be set to default to select the entire image (no coords attribute necessary), circle or circ for a circle, rectangle or rect for a rectangle, and polygon or poly for a polygonal area specified by corner points.

Introduction to Image Maps

Description

An image maps is an image with clickable areas that usually act as hyperlinks.

The image is defined by the <img> tag, and the map is defined by a <map> tag with <area> tags to denote each clickable area. Use the usemap and name attributes to bind the image and the map.

Advertisement

Basic Example

To create an image map so that each of the shapes in the image below are clickable:

The code would be as follows:

Advertisement
<img src="http://jaced.com/blogpix/2007/trisquarecircle/002.gif" usemap="#shapes">
<map name="shapes">
 <area shape="polygon" coords="79,6,5,134,153,134">
 <area shape="rectangle" coords="177,6,306,134">
 <area shape="circle" coords="397,71,65">
</map>

You should see that the browser recognizes the areas when the cursor becomes a pointer. See a live demo on
JSFiddle

Recent Posts

Securing phpMyAdmin Like a Pro: Essential Tips and Tricks

Securing phpMyAdmin is crucial to prevent unauthorized access and protect your databases. Here's a guide…

6 months ago

Pasqal raises $100M to build a neutral atom-based quantum computer

Pasqal, a Paris-based quantum computing startup, today announced that it has raised a $100 million…

1 year ago

Apple in talks with Disney, others on VR content for new headset: Report

Developed with Sony Group Corp, the headset will have two ultra-high-resolution displays to handle the…

1 year ago

Microsoft, Amazon results to highlight softening cloud business

After years of blistering growth, most recently fuelled by remote working and studying during the…

1 year ago

Intel chairman Omar Ishrak steps down

Omar Ishrak had stepped down and the chipmaker appointed board director Frank Yeary as his…

1 year ago

Canada to commercialise world's first photonic-based quantum computer

Canadian Prime Minister Justin Trudeau has announced a new federal investment to build and commercialise…

1 year ago