map
The HTML <map> element groups clickable regions for an image map. It connects an <img> to one or more <area> links.
What you will learn
- How
map,area, andimgwork together - How
usemapandnameconnect the image map - Why an alternative navigation path should not depend on the image alone
Basic example
<img src="campus.png" alt="Campus map" usemap="#campus-map">
<map name="campus-map">
<area shape="rect" coords="0,0,120,80"
href="library.html" alt="Library">
<area shape="circle" coords="220,60,35"
href="cafe.html" alt="Cafe">
</map>
The value in usemap begins with # and must match the map’s name. Each area then defines a shape, coordinates, destination, and alternative label.
map groups; area does the linking
map is the container for the regions. It does not define clickable behavior by itself. The area elements inside it create the individual links.
Accessibility and alternatives
- Give the
imguseful alternative text that explains the whole image’s purpose. - Give each linked
areaanaltthat names its destination. - Provide ordinary text links when the image map contains important navigation.
- Check keyboard navigation and do not rely only on color or visual coordinates.
Common mistakes
- Forgetting the leading
#inusemap. - Using a different map
namethan the image reference. - Leaving linked regions without useful
alttext. - Using an image map where a normal list of links would be clearer.