map

Defines an image map with clickable regions linked to an img element via the usemap attribute. Coordinates are pixel-based and do not scale responsively.

Description

The <map> element defines a client-side image map — a set of clickable regions overlaid on an image. Each region is defined by an <area> child element with pixel-based coordinates. The map is linked to an <img> via the usemap attribute.

Image maps were designed for fixed-size images in the early web. The coordinate system uses absolute pixel values, which means hotspot regions break when the image scales to a different size — a serious limitation in responsive layouts.

Basic Example

Hover over a room to see its title tooltip. Click to see the area name in the status bar. This demo renders the image at its native 800×500 pixels so the pixel-based coordinates align correctly.

How It Works

The <map> and <img> are connected through two attributes:

  1. The <map> element has a name attribute (e.g. name="office")
  2. The <img> has a usemap attribute with a hash reference (e.g. usemap="#office")

The browser renders the image normally. When the user clicks or taps within a region defined by an <area>, the browser navigates to that area’s href.

Attributes

AttributeTypeRequiredDescription
name string Yes Unique name referenced by the usemap attribute on an <img>. Must not contain spaces.

The <map> element also supports global attributes.

The Responsive Problem

Native <map> coordinates are defined in absolute pixels matching the image’s natural dimensions. Modern layouts scale images fluidly with max-inline-size: 100%, but the coordinate system does not scale with them. The result: hotspot regions drift away from their visual targets as the image shrinks or grows.

Workarounds exist (JavaScript that recalculates coordinates on resize), but they add complexity and fragility. The native element was not designed for responsive use.

Modern Alternative

Vanilla Breeze provides <image-map> as a modern replacement for native <map>/<area>:

FeatureNative <map>VB <image-map>
Coordinate systemAbsolute pixelsPercentages (0–100)
ResponsiveNoYes
Tooltipstitle text onlyRich HTML content
Keyboard navigationTab onlyTab + Arrow keys + Escape
Visual feedbackNoneSVG overlay with hover highlight
Progressive enhancementN/A (native)Falls back to labeled list

Accessibility

  • Every <area> must have an alt attribute describing the linked region
  • The <img> itself needs an alt describing the overall image
  • Native image maps support keyboard navigation via Tab between areas
  • Screen readers announce area alt text as link text
  • No visual focus indicator exists on native areas — users cannot see which region has focus

Browser Support

The <map> element has universal browser support dating back to the earliest HTML specifications. However, it was designed for an era of fixed-width layouts and offers no adaptation for modern responsive design.

Related

  • <area> — defines clickable regions within an image map
  • <img> — the image element that references a map via usemap
  • <image-map> — modern responsive replacement with percentage coordinates