🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

<map>

AI & DATA SCIENCE // map-tag

The <map> element defines a client-side image map — a set of clickable regions overlaid on an image, using nested <area> elements.

Syntax

<img src="/office-map.png" usemap="#officemap" alt="Office floor plan">
<map name="officemap">
  <area shape="rect" coords="0,0,100,100" href="/reception" alt="Reception">
</map>

Deep Dive Course

**`<map>`** links to an `<img>` via matching **`name`**/**`usemap`** attributes (note the `#` prefix on `usemap`, referencing the map's name like an anchor), and contains one or more `<area>` children, each defining a clickable region with specific pixel coordinates. This technique — an 'image map' — lets a single image act like several different links depending on where the user clicks, such as a diagram where clicking different parts of a building floor plan navigates to different pages.

1Understanding <map>

`<map>` links to an <img> via matching `name`/`usemap` attributes (note the # prefix on usemap, referencing the map's name like an anchor), and contains one or more <area> children, each defining a clickable region with specific pixel coordinates. This technique — an 'image map' — lets a single image act like several different links depending on where the user clicks, such as a diagram where clicking different parts of a building floor plan navigates to different pages.

💡

Image maps with hardcoded pixel coordinates don't adapt well to responsive/resized images — if the image is scaled by CSS, the clickable areas won't line up correctly, which is why image maps are much less common on modern responsive sites than they were in the past.

editor.html
<img src="/world-map.png" usemap="#worldmap" alt="World map">
<map name="worldmap">
  <area shape="rect" coords="34,44,270,350" href="/regions/americas" alt="Americas">
  <area shape="rect" coords="290,44,540,300" href="/regions/europe" alt="Europe">
</map>
localhost:3000

2Practical Example

Here is a real-world application of <map> showing how it is used in production HTML.

editor.html
<!-- A circular clickable area -->
<area shape="circle" coords="100,100,50" href="/details" alt="Highlighted zone">
localhost:3000

3Best Practices

Follow these guidelines when working with <map>:

1. Use image maps only for genuinely irregular clickable regions an image demands (like a geographic map or diagram)

2. Always give each <area> descriptive alt text for accessibility

3. Consider whether separate, individually-linked images or SVG with real HTML elements would be more responsive-friendly instead

⚠️

Tip: Image maps with hardcoded pixel coordinates don't adapt well to responsive/resized images — if the image is scaled by CSS, the clickable areas won't line up correctly, which is why image maps are much less common on modern responsive sites than they were in the past.

editor.html
<img src="/world-map.png" usemap="#worldmap" alt="World map">
<map name="worldmap">
  <area shape="rect" coords="34,44,270,350" href="/regions/americas" alt="Americas">
  <area shape="rect" coords="290,44,540,300" href="/regions/europe" alt="Europe">
</map>
localhost:3000

Examples

Example 01Basic Usage
<img src="/world-map.png" usemap="#worldmap" alt="World map">
<map name="worldmap">
  <area shape="rect" coords="34,44,270,350" href="/regions/americas" alt="Americas">
  <area shape="rect" coords="290,44,540,300" href="/regions/europe" alt="Europe">
</map>
Example 02Advanced Example
<!-- A circular clickable area -->
<area shape="circle" coords="100,100,50" href="/details" alt="Highlighted zone">

Best Practices

  • Use image maps only for genuinely irregular clickable regions an image demands (like a geographic map or diagram)
  • Always give each descriptive alt text for accessibility
  • Consider whether separate, individually-linked images or SVG with real HTML elements would be more responsive-friendly instead

Interview Question

Why are image maps less common on modern responsive websites than they were in the past?

Hint: Think about what happens to hardcoded pixel coordinates when an image is resized by CSS for different screen sizes.

An image map's <area> coordinates are fixed pixel values tied to the image's original dimensions. When CSS resizes the image responsively for different screen widths, those hardcoded coordinates no longer line up with the visually scaled image, making clickable regions misaligned or unusable. Modern alternatives — like inline SVG with real, individually-styleable and scalable shape elements, each as its own link — handle responsive resizing correctly, which is why they're generally preferred today.

Exercises

EasyPractice using <map> in a real scenario.
View Solution
<img src="/world-map.png" usemap="#worldmap" alt="World map">
<map name="worldmap">
  <area shape="rect" coords="34,44,270,350" href="/regions/americas" alt="Americas">
  <area shape="rect" coords="290,44,540,300" href="/regions/europe" alt="Europe">
</map>

Frequently Asked Questions

Why are image maps less common on modern responsive websites than they were in the past?

An image map's coordinates are fixed pixel values tied to the image's original dimensions. When CSS resizes the image responsively for different screen widths, those hardcoded coordinates no longer line up with the visually scaled image, making clickable regions misaligned or unusable. Modern alternatives — like inline SVG with real, individually-styleable and scalable shape elements, each as its own link — handle responsive resizing correctly, which is why they're generally preferred today.

Related Functions

area-tagimg-tag