HTML Image Maps
In this page:
<img src="image-url" usemap="#mapname" alt="Description">
<map name="mapname">
<area shape="rect" coords="x1,y1,x2,y2" href="url" alt="Description">
</map>
What Is an Image Map?
An image map turns a single image into a clickable surface with several selectable regions, each linking to a different destination, instead of splitting one image into many separate linked images.
- Image maps work best for genuinely image-based navigation, like a diagram or a real map, not as a substitute for a simple menu.
- Accepted attributes:
- img usemap — #mapname
- map name — mapname
- area shape / coords / href / alt
Example: What Is an Image Map?
<img src="map.jpg" usemap="#worldmap" alt="World map">
<map name="worldmap">
<area shape="rect" coords="0,0,100,100" href="asia.html" alt="Asia">
</map>
The usemap Attribute on <img>
The usemap attribute connects an <img> element to a <map> element by referencing the map's name, prefixed with a hash symbol, similar to linking to an in-page anchor.
- Keep each map's name short and unique so it never collides with another map elsewhere on the page.
- Accepted values:
- usemap — hash-name reference, e.g. #planetmap
- Must match a map element name
Example: The usemap Attribute on <img>
<img src="diagram.jpg" usemap="#parts" alt="Diagram">
<map name="parts"></map>
Defining Clickable Areas with <area>
Each <area> element inside a <map> defines one clickable region, complete with its own href, alt text, and shape. Multiple <area> elements can sit inside a single map to create several hotspots on one image.
- List area elements in the order they visually appear, which also affects the tab order for keyboard navigation.
- Accepted attributes:
- shape — rect | circle | poly | default
- coords — depends on shape
- href — link URL
- alt — required text alternative
- target — _self | _blank | _parent | _top
Example: Defining Clickable Areas with <area>
<map name="parts">
<area shape="rect" coords="0,0,50,50" href="engine.html" alt="Engine">
<area shape="rect" coords="51,0,100,50" href="wheel.html" alt="Wheel">
</map>
The shape and coords Attributes
The shape attribute defines the geometry of a clickable area (rect, circle, or poly), while coords supplies the numeric coordinates that position and size that shape relative to the image's top-left corner.
- Use an image editor or browser devtools to read pixel coordinates accurately before writing your coords values.
- Accepted values:
- rect — coords=x1,y1,x2,y2
- circle — coords=x,y,radius
- poly — coords=x1,y1,x2,y2,... pairs
- default — whole image; no coords
Example: The shape and coords Attributes
<map name="shapes">
<area shape="circle" coords="50,50,30" href="center.html" alt="Center">
</map>
Accessibility for Image Maps
Every <area> element needs meaningful alt text, just like a regular link, so that screen reader users understand each region's destination even though the shapes themselves are invisible to assistive technology.
Example: Accessibility for Image Maps
<map name="parts">
<area shape="rect" coords="0,0,50,50" href="engine.html" alt="Go to Engine details">
</map>
- Forgetting to match the usemap value to the connected map's name attribute, including the leading '#'.
- Using coordinate values that don't line up with the actual visible regions of the image.
- Leaving out alt text on area elements, making the map unusable for screen reader visitors.
- The <map> element defines a named set of clickable areas linked to an image through usemap.
- Each <area> element defines one clickable region using a shape and matching coords.
- Always provide alt text on every <area> element for accessibility.
Image maps are supported natively by every modern browser.
Chapter Quiz — Complete all 20 topics to unlock
0/20 topics done
Complete these topics first:
- HTML Keyboard Shortcuts
- HTML Browser Support
- HTML Character Sets
- HTML Doctypes
- HTML Audio/Video Reference
- HTML Meta Tags
- HTML ARIA Roles
- HTML Input Validation
- HTML Iframe Security
- HTML Responsive Images
- HTML Web Fonts
- HTML Icon Fonts
- HTML Progress & Meter
- HTML Output Element
- HTML Datalist
- HTML Image Maps
- HTML Browser DevTools
- HTML Validation
- HTML Quiz
- HTML Interview Prep