HTML shape Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The shape attribute on an <area> chooses the geometry of a clickable hotspot in an image map: rect, circle, poly, or default.

Pair it with coords (except for default). Put areas inside a <map>, and link the <img> with usemap="#map-name". Linked areas also need meaningful alt text.

Baseline · Widely available.

Not deprecated and not experimental. Stable image-map attribute across modern browsers since about July 2015.

Shape and coords must match.

Wrong formats (for example four numbers with circle) produce broken or ignored hotspots. Omit coords when shape="default".

HTML Syntax

syntax.html
<area shape=" rect|circle|poly|default" …>

Then add the matching coords (unless default), plus href and alt when the area is a link.

Attribute Values

HTML defines these shape keywords:

ValueMeaning + coordsTry it
rectRectangle — coords="x1,y1,x2,y2"Try it
circleCircle — coords="x,y,radius"Try it
polyPolygon — coords="x1,y1,x2,y2,…"Try it
defaultRest of the image — omit coordsTry it

Live Preview

Switch the hotspot shape. Click the image region that matches (demo link stays on this page).

Click the logo hotspot. The note below shows the live shape and matching coords.

image map
JavaScript logo used as an image map demoDemo hotspot — stays on this page

shape="rect" coords="0,0,128,128"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Rectangle (shape="rect")

Four coordinates: top-left and bottom-right corners.

HTML
<img src="/images/javascript.png" alt="JavaScript logo" usemap="#rect-map" width="128" height="128">
<map name="rect-map">
  <area shape="rect" coords="0,0,128,128" href="/js/interview" alt="Learn JavaScript">
</map>
Try It Yourself

How It Works

  1. usemap on the image must match the map’s name (with a leading #).
  2. shape="rect" selects a rectangular hotspot.
  3. coords="0,0,128,128" covers the full 128×128 image.
  4. href + alt make the hotspot a real, accessible link.

Example 2 — Circle (shape="circle")

Three coordinates: center x, center y, then radius.

HTML
<img src="/images/javascript.png" alt="JavaScript logo" usemap="#circle-map" width="128" height="128">
<map name="circle-map">
  <area shape="circle" coords="64,64,55" href="/js/interview" alt="Learn JavaScript">
</map>
Try It Yourself

How It Works

  1. shape="circle" tells the browser to expect three numbers.
  2. 64,64 is the center of a 128×128 image.
  3. 55 is the radius in CSS pixels.
  4. Clicks outside the circle do not activate this area.

Example 3 — Polygon (shape="poly")

Pairs of x,y vertices (at least three). The browser closes the path if needed.

HTML
<img src="/images/javascript.png" alt="JavaScript logo" usemap="#poly-map" width="128" height="128">
<map name="poly-map">
  <area shape="poly" coords="0,128,64,0,128,128" href="/js/interview" alt="Learn JavaScript">
</map>
Try It Yourself

How It Works

  1. shape="poly" expects an even-length list of numbers.
  2. Three pairs form a triangle: bottom-left, top-center, bottom-right.
  3. Browser closes the polygon if the first and last points differ.
  4. Use for irregular regions that rectangles and circles cannot cover cleanly.

Edge Cases & Pitfalls

Most image-map bugs come from mismatched shape/coords or scaled images.

pair

Match shape to coords format

rect needs 4 numbers, circle needs 3, poly needs pairs. Mixing them breaks the hotspot.

default

default skips coords

shape="default" is the leftover image region. Omit coords for that area.

scale

CSS scaling can misalign hits

Coordinates are based on the image’s intrinsic pixel grid. Prefer matching width/height attributes to the map.

a11y

alt is required when href is set

Describe the same choice the visual hotspot offers. Empty or missing alt hurts keyboard and screen reader users.

order

Earlier areas win overlaps

If shapes overlap, the first matching <area> in the map usually takes the click. Put specific shapes before default.

Browser Support

shape is an attribute of the HTML <area> element in client-side image maps. It is not a Node.js API.

✓ Baseline · Widely available

shape

Widely available since about July 2015. Supported across modern browsers for rect, circle, poly, and default.

98% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet Modern
Full support
Internet Explorer Legacy support
Supported
shape Widely supported

Bottom line: Safe to use for image maps. Keep width/height stable, pair shape with the correct coords, and always provide alt on linked areas.

Key Takeaways

  • Role: pick hotspot geometry on <area>.
  • Values: rect, circle, poly, default.
  • Wiring: <map> + usemap on <img>.
  • A11y: linked areas need clear alt text.

One line: shape picks the hotspot type — coords fills in the numbers.

Frequently Asked Questions

On an area element inside a map, shape chooses the hotspot geometry: rect (rectangle), circle, poly (polygon), or default (the whole image beyond other areas).
Only area (inside map). The image links to the map with usemap. Do not put shape on img.
rect uses x1,y1,x2,y2. circle uses x,y,radius. poly uses x1,y1,x2,y2,... (at least three pairs). default omits coords.
It covers the remaining image region after other areas. Use it for a catch-all link. Do not set coords with default.
When the area has href, provide meaningful alt text so keyboard and assistive-tech users get the same choice the image offers.
Image maps with shape are Baseline widely available. Hotspots can misalign if CSS scales the image without matching coordinates.

Next: size

Control visible rows on select, or character width on text inputs.

size tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful