Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

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 be empty or contain spaces.

If the <map> also has an id, the spec requires the id to equal the name.

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, 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.

In a VB page this happens with no author CSS at all. The reset gives every <img> max-inline-size: 100%, so as soon as the container is narrower than the image, the image shrinks and the hotspots stay where they were.

To keep a native map accurate, stop the image from shrinking and let it scroll instead. This is what the demo above does:

Other workarounds (JavaScript that recalculates coordinates on resize) 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
  • Browsers draw the focus ring around the area’s shape. VB styles it with :focus-visible in the theme’s interactive colour; on a busy image it can still be hard to see, so keep hotspots on calm regions or add visible labels.

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
↑