HTML Image Maps
The Picture element chooses among image files. An image map keeps one image and makes regions of it clickable — hotspots on a floor plan, a diagram, or a simple graphic menu. You pair an img that has usemap with a <map> full of <area> links.
What an image map is
An image map is not a separate image format. It is HTML that says: “this rectangle (or circle, or polygon) on the picture should behave like a link.” Sighted users click the zone; assistive tech needs a clear alt on each area because there may be no visible text beside the hotspot.
Direct answer
- Add
usemap="#mapname"on theimg. - Add
<map name="mapname">with one or more<area>elements. - Each
areaneedsshape,coords,href, and its ownalt.
The#onusemapmust match the map’sname(without inventing a second spelling).
Shape values at a glance
📊 area shape values
| shape | Meaning |
|---|---|
| rect | Rectangle — coords: left, top, right, bottom |
| circle | Circle — coords: centerX, centerY, radius |
| poly | Polygon — list of x,y points in order |
A simple rectangular map
Two hotspots on a desk layout is enough to learn the wiring: usemap, matching name, and area rectangles with honest alt text.
Simple rectangular hotspots
html<img src="images/desk.png" alt="Desk layout" usemap="#deskmap" width="400" height="200">
<map name="deskmap">
<area shape="rect" coords="20,30,120,100" href="lamp.html" alt="Lamp">
<area shape="rect" coords="200,40,320,120" href="monitor.html" alt="Monitor">
</map>
Reading the sample
usemap="#deskmap"on the image points to the map nameddeskmap- Each
areais a link:hrefis the destination,altnames the hotspot coordsforrectare left, top, right, bottom in the image’s pixel grid- The image’s own
alt(“Desk layout”) describes the whole graphic; area alts name the zones
How coordinates work
Coordinates are measured in CSS pixels of the image as laid out for the map. If you set width and height on the img, keep your coords consistent with that display size while you learn. Wrong numbers produce hotspots that miss the drawn objects — a common silent failure.
Accessibility habits
Every clickable area needs a meaningful alt. Do not leave hotspots unnamed. Prefer maps where the purpose of each region is obvious. If the design needs complex responsive behavior, many teams switch to SVG with links or separate buttons instead of fragile pixel maps.
When maps help — and when they do not
Maps help for a single diagram with a few stable regions. They get awkward when the image scales freely across many breakpoints, because classic coords do not automatically rewrite themselves. For modern responsive UIs, consider separate linked images, CSS layout, or SVG. Still, knowing image maps helps when you inherit older pages or simple teaching demos.
Circle and poly (quick note)
circle uses center and radius. poly lists pairs of x,y points around a free shape. Start with rect until the usemap / name pairing feels natural, then experiment with other shapes on a practice graphic.
Practice in your editor
- Use a simple wide image with two obvious regions.
- Create a
mapwith tworectareas linking to two small practice pages. - Match
usemap="#name"tomap name="name"carefully (including the#). - Click each region and confirm navigation.
- Break the name match once, observe the dead hotspots, then fix it.
- Improve any
areawhosealtonly says “link.”
Easy mistakes
- Mismatched
usemap/name(forgetting#onusemapor renaming only one side) - Missing
alton eacharea - Coords that do not match the real image size or object positions
- Relying on image maps for highly fluid responsive layouts without a plan
- Putting the only description on the
imgand leaving areas unlabeled
Summary
- Image maps wire
img+usemap+map+area - Shapes include
rect,circle, andpoly - Each area needs
href,alt,shape, andcoords - Keep names matched and coords honest
- For complex responsive UIs, consider modern alternatives — still learn maps for legacy and simple diagrams
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top