HTML Image Maps: Clickable Image Regions
Connect an image to a map
usemap on img points to a named map using a hash prefix. Each linked area defines a region and has a meaningful alt for the destination. The map name must be unique within the document. The example uses a fixed-size drawing so coordinates match.
<img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22240%22%20height%3D%22100%22%20viewBox%3D%220%200%20240%20100%22%3E%3Crect%20width%3D%22120%22%20height%3D%22100%22%20fill%3D%22%23bfdbfe%22%2F%3E%3Crect%20x%3D%22120%22%20width%3D%22120%22%20height%3D%22100%22%20fill%3D%22%23bbf7d0%22%2F%3E%3Ctext%20x%3D%2215%22%20y%3D%2255%22%3ELibrary%3C%2Ftext%3E%3Ctext%20x%3D%22135%22%20y%3D%2255%22%3EGarden%3C%2Ftext%3E%3C%2Fsvg%3E" alt="Campus plan with library and garden" width="240" height="100" usemap="#campus"><map name="campus"> <area shape="rect" coords="0,0,120,100" href="#library" alt="Library"> <area shape="rect" coords="120,0,240,100" href="#garden" alt="Garden"></map><h2 id="library">Library</h2><h2 id="garden">Garden</h2>The left and right halves are links to the corresponding headings.
Understand coordinate shapes
Coordinates use CSS pixels from the top-left of the image. rect uses x1,y1,x2,y2; circle uses center x, center y, radius; poly uses successive x,y pairs for polygon vertices. default covers the remaining image when placed after other areas. If display sizing changes, recheck the hit regions.
<img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22120%22%20height%3D%22120%22%20viewBox%3D%220%200%20120%20120%22%3E%3Ccircle%20cx%3D%2260%22%20cy%3D%2260%22%20r%3D%2240%22%20fill%3D%22%23bfdbfe%22%2F%3E%3C%2Fsvg%3E" alt="Circular meeting area" width="120" height="120" usemap="#meeting"><map name="meeting"> <area shape="circle" coords="60,60,40" href="#meeting-room" alt="Meeting room"></map><h2 id="meeting-room">Meeting room</h2>The circle is centered at (60,60) with radius 40.
Provide ordinary links too
Image maps can be awkward on small screens and for users who do not interact visually. Supply visible text links to the same destinations and preserve usable keyboard access. Prefer ordinary links for simple navigation. Avoid server-side ismap for this task.
<img src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22240%22%20height%3D%22100%22%20viewBox%3D%220%200%20240%20100%22%3E%3Crect%20width%3D%22120%22%20height%3D%22100%22%20fill%3D%22%23bfdbfe%22%2F%3E%3Crect%20x%3D%22120%22%20width%3D%22120%22%20height%3D%22100%22%20fill%3D%22%23bbf7d0%22%2F%3E%3Ctext%20x%3D%2215%22%20y%3D%2255%22%3ELibrary%3C%2Ftext%3E%3Ctext%20x%3D%22135%22%20y%3D%2255%22%3EGarden%3C%2Ftext%3E%3C%2Fsvg%3E" alt="Campus plan" width="240" height="100" usemap="#places"><map name="places"> <area shape="rect" coords="0,0,120,100" href="#library" alt="Library"> <area shape="rect" coords="120,0,240,100" href="#garden" alt="Garden"></map><ul> <li> <a href="#library">Library</a> </li> <li> <a href="#garden">Garden</a> </li></ul><h2 id="library">Library</h2><h2 id="garden">Garden</h2>Both destinations also have ordinary text links.
Practice and next steps
Add a third destination to a sketch and calculate its coordinates. Keep a matching text link.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Image Maps: Clickable Image Regions — Knowledge Check
Check the core concepts from this lesson.
Which usemap value matches map name="campus"?
What does circle coords="60,60,40" mean?
What makes map destinations easier to access?
Which element defines an individual clickable region in a map?
What should an area with an href provide for a meaningful destination?