<map>
An image map: clickable regions defined by `<area>` elements.
- Display
- inline
- Closing tag
- Required
- Permitted content
- Transparent content, usually
<area>elements
Example
#<img
src="/collections/covers/python-czy-javascript.webp"
alt="Two desks: on the left a monitor with charts, on the right a laptop with a web page design"
width="360"
height="240"
usemap="#paths"
>
<map name="paths">
<area shape="rect" coords="0,0,180,240" href="/en/docs/python" alt="Python documentation: data analysis">
<area shape="rect" coords="180,0,360,240" href="/en/docs/javascript" alt="JavaScript documentation: building web pages">
</map>The left half of the image leads to the Python documentation, and the right half to the JavaScript documentation. Hover over the regions or move through them with the Tab key.
Definition and usage
#The <map> element together with <area> elements creates an image map, an image in which different parts lead to different addresses. You connect the map to the image with the usemap attribute of the <img> element, giving the name of the map preceded by #.
Each clickable part is described by an <area>: its shape, coordinates, address, and alternative text. The regions are invisible, but they can be reached with the Tab key, and screen readers read them out like ordinary links.
Image maps date from the early years of the web and have a serious drawback: coordinates are given in pixels, so the regions don’t scale with the image in a responsive layout. Today a similar effect is more often achieved by overlaying the image with links positioned in CSS, or by drawing clickable shapes in <svg>.
Syntax
#<img src="…" alt="…" usemap="#name">
<map name="name">
<area shape="rect" coords="…" href="…" alt="…">
</map>Attributes
#name
text (required)
The name of the map that the image’susemap="#name"attribute refers to. It must not contain spaces, and if the element also has anid, both values must be identical.
The element also supports all global attributes, such as class, id, style and hidden.
Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Every
<area>with an address must havealt. Without it a screen reader has no way to name the region. - If the image changes size on different screens, the map regions will no longer line up. In that case, links overlaid in CSS or an
<svg>will work better.
Related entries
#Spotted a mistake or missing an example? Write to us.