HTMLImageElement: useMap property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The useMap property of the HTMLImageElement interface providing the name of the client-side image map to apply to the image. It reflects the <img> element's usemap content attribute.

Value

A string providing a valid anchor to a <map> element, formed by prepending the hash character # to the map's name attribute.

You can learn more about client-side image maps in our learning article Add a hitmap on top of an image.

Examples

Consider a <map> that looks like this:

html
<map name="mainmenu-map">
  <area
    shape="circle"
    coords="25, 25, 75"
    href="/index.html"
    alt="Return to home page" />
  <area shape="rect" coords="25, 25, 100, 150" href="/index.html" alt="Shop" />
</map>

You could set useMap like this:

js
const menuBox = document.getElementById("menu-box");
menuBox.useMap = "#mainmenu-map";

Specifications

Specification
HTML
# dom-img-usemap

Browser compatibility

See also