Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Images and Media

The <map> element

Reference for the HTML <map> element: how it groups <area> hotspots, how usemap connects it to an image, the name attribute rules, accessibility and technical details.

The <map> element defines an image map: a set of clickable regions laid over an image. The regions themselves are <area> elements inside the map. An <img> uses the map by naming it in its usemap attribute, with a # in front.

The map is not visible by itself. It only adds behavior to the image (or images) that refer to it, so one map can serve several copies of the same picture.

HTML
<img src="/images/floor-plan.png" alt="Floor plan" width="600" height="400" usemap="#floor">

<map name="floor">
  <area shape="rect" coords="0,0,300,400" href="/rooms/east" alt="East wing">
  <area shape="rect" coords="300,0,600,400" href="/rooms/west" alt="West wing">
</map>

Try it

One map, two regions

The script uses the map's areas property, a live collection of all its <area> descendants.

Attributes

Attribute Values Description
name Text with no spaces The map's name, which usemap="#name" refers to. Required, must not be empty, must not contain whitespace and must be unique among the page's maps. If the map also has an id, both must have the same value.

It also accepts the global attributes.

Usage notes

  • Don't forget the #. usemap="halves" does nothing; it must be usemap="#halves". The value is matched against the map's name (or its id).
  • Placement. The map can sit anywhere in the document; it doesn't have to follow the image. Keeping it right after the image makes the code easier to follow.
  • Transparent content. A <map> may contain other content as well as areas, such as a list of the same links in text form. That content is rendered normally, which makes a handy visible fallback.
  • Accessibility. Each linked area is a focusable link named by its alt text. Give every area a meaningful alt, and give the image its own alt that describes the picture as a whole.
  • Responsive layouts. Area coordinates are fixed pixels and don't follow the image when CSS scales it. An inline <svg> with links scales cleanly and is often the better choice today.

Technical summary

Content categories Flow content, phrasing content, palpable content
Permitted content Transparent (typically <area> elements, plus any content its parent allows)
Tag omission None; both the start and end tags are required
Permitted parents Any element that accepts phrasing content
Implicit ARIA role No corresponding role
DOM interface HTMLMapElement
Default display inline

Browser support

Supported in every browser.

  • <area> โ€“ a single clickable region
  • <img> โ€“ the image that uses the map
  • <svg> โ€“ scalable graphics with real links
  • Lesson: Image Maps
  • Lesson: Images