👀 Live Preview
Minimal image map linking two rectangular regions on one image:

The usemap attribute is a powerful HTML feature for creating client-side image maps. It connects an image (or object) to a <map> element so you can define clickable regions — each linking to a different URL.
Image maps are useful for diagrams, floor plans, infographics, and navigation graphics where different parts of one image should go to different pages. Each hotspot is an <area> inside the map.
Hash reference.
Hotspot markup.
rect, circle, poly.
Pixel positions.
useMap prop.
alt on areas.
usemapThe primary purpose of the usemap attribute is to connect an image with a client-side image map. It is applied to <img> (most common) or <object> and references a corresponding <map> element where clickable <area> regions are defined.
Without usemap, the image is a single link at most. With it, you can turn one graphic into a multi-link navigation surface.
usemap creates a client-side map in HTML. Older server-side image maps (ISMAP) are obsolete. Modern pages use HTML <map> + <area>.
Set usemap on the image and define matching name on <map>:
<img src="diagram.png" alt="Site map" usemap="#siteMap">
<map name="siteMap">
<area shape="rect" coords="0,0,100,80" href="/home" alt="Home section">
</map>#mapName — hash plus the name on <map>.<area> needs shape, coords, and usually href + alt.HTMLImageElement.useMap (same hash string).The usemap attribute accepts a hash-name reference pointing to a <map> element:
#mapName — Must match name="mapName" on the <map> element.#) is required in the attribute value.worldMap).<img src="example.jpg" alt="Example Image" usemap="#exampleMap">
<map name="exampleMap">
<!-- area elements defined here -->
</map>In this pattern, usemap="#exampleMap" tells the browser to use the map named exampleMap. Clicks inside defined <area> regions follow each area’s href.
| Part | Attribute / value | Role |
|---|---|---|
| Image | usemap="#myMap" | Links image to map |
| Map | name="myMap" | Named target for usemap |
| Rectangle | shape="rect" coords="L,T,R,B" | Box hotspot |
| Circle | shape="circle" coords="X,Y,R" | Round hotspot |
| Polygon | shape="poly" coords="x1,y1,x2,y2,..." | Custom shape |
| JavaScript | img.useMap = "#otherMap" | Switch active map |
| Element | Supported? | Typical use |
|---|---|---|
<img> | Yes | Most common — clickable photo or diagram |
<object> | Yes | Image maps on embedded image content |
<input type="image"> | Yes | Image submit button with hotspots |
<map> | N/A | Defines areas; referenced by usemap |
<area> | N/A | Child of map; each hotspot link |
| Approach | Best for | Notes |
|---|---|---|
usemap + <map> | Raster images (PNG, JPG) | Classic HTML; fixed pixel coords |
One <a> wrapping <img> | Single destination | Simpler; whole image is one link |
Inline SVG with <a> | Scalable vector graphics | Better for responsive multi-link diagrams |
| CSS positioned links | Overlays on images | Flexible layout; more manual work |
Build a three-zone image map, switch maps with JavaScript, and use rect, circle, and polygon shapes.
Minimal image map linking two rectangular regions on one image:
A world-map style layout with two rectangular regions (extend with more <area> elements as needed):
<img src="world-map.jpg" alt="World Map" usemap="#worldMap">
<map name="worldMap">
<area shape="rect" coords="0,0,100,100" href="north-america.html" alt="North America">
<area shape="rect" coords="100,0,200,100" href="europe.html" alt="Europe">
</map>usemap="#worldMap" connects the image to the map named worldMap. Each <area> defines a rectangle with coords as left,top,right,bottom in pixels.
Switch which map is active when the user clicks a button:
<button type="button" onclick="updateMap()">Change Map</button>
<img id="dynamicImage" src="diagram.png" alt="Dynamic Map" usemap="#defaultMap">
<map name="defaultMap">...</map>
<map name="dynamicMap">...</map>
<script>
function updateMap() {
document.getElementById("dynamicImage").useMap = "#dynamicMap";
}
</script>Clicking Change Map runs updateMap(), which sets useMap to #dynamicMap. The same image now uses different hotspot definitions without changing src.
Not every hotspot is a rectangle. Use circle and poly for other shapes:
<map name="shape-map">
<area shape="circle" coords="80,80,50" href="/circle" alt="Circle zone">
<area shape="poly" coords="200,30,260,130,140,130" href="/triangle" alt="Triangle zone">
</map>Circle coords are center X, center Y, radius. Polygon coords are comma-separated x,y pairs for each vertex. Always match coords to the image’s natural dimensions.
alt on every <area> — Describes each hotspot for screen readers (required for meaningful maps).alt on the image — Summarize the whole graphic, not just “image map.”Hotspots in HTML.
#mapName on img.
Browser tests coords.
Multi-link image.
Client-side image maps with usemap are supported in all modern browsers and have been a standard HTML feature for many years. Test coordinate accuracy when images are scaled with CSS.
Image maps work in Chrome, Firefox, Safari, and Edge. Watch for responsive scaling issues with fixed pixel coordinates.
Bottom line: Safe to use; recalculate coords if the displayed image size differs from its natural size.
usemap="#name" to map name="name"alt on every <area>coords (left < right, top < bottom for rect)# prefix in the usemap valuealt text<map> contains <area> elements with correct coordinates and destination links.The usemap attribute is a valuable tool for creating interactive image maps, allowing you to define multiple clickable areas within a single image. Used with <map> and <area>, it enhances navigability for diagrams and visual layouts.
Understanding static markup and dynamic updates with JavaScript helps you build engaging pages while keeping hotspots accessible and well labeled.
usemapBookmark these before your next usemap implementation.
usemap="#mapName" links an <img> to a <map name="mapName">.
Hotspots are <area> elements with shape, coords, and href.
Coordinates are pixel-based on the image’s natural size.
UsageChange maps at runtime with image.useMap = "#otherMap".
name attribute on <map>. The usemap value is # plus that name (e.g. usemap="#worldMap" with name="worldMap").left,top,right,bottom in pixels, where left < right and top < bottom.Try three clickable zones, then switch maps with JavaScript.
5 people found this page helpful