HTML shape Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Image Maps

Introduction

The shape attribute is used on <area> elements inside an HTML image map. Together with coords, it defines the geometry of each clickable region on an image linked via usemap. Values include rect, circle, poly, and default.

What You’ll Learn

01

<area>

Where shape applies.

02

rect

Rectangle regions.

03

circle

Round hotspots.

04

poly

Custom polygons.

05

coords

Pair with shape.

06

JavaScript

area.shape API.

Purpose of shape

The primary purpose of the shape attribute is to tell the browser what kind of geometry the coords values describe for a clickable hotspot. Image maps let one image link to multiple destinations—a floor plan, a product diagram, or a navigation graphic with distinct regions.

By choosing the correct shape, you match the hotspot to the visual region: rectangles for boxes, circles for round buttons, polygons for irregular outlines, and default for anywhere not covered by other areas.

💡
Always pair with coords

shape alone does nothing useful. Every <area> needs matching coords, plus href (or alternative behavior) and descriptive alt text.

📝 Syntax

Add shape to <area> elements inside a <map> linked from an <img usemap>:

shape.html
<img src="diagram.png" alt="Product diagram" usemap="#productMap">

<map name="productMap">
  <area shape="rect" coords="0,0,50,50" href="/part-a" alt="Part A">
</map>

Syntax Rules

  • Valid on <area> elements inside <map>.
  • Value must be one of: rect, circle, poly, or default.
  • Must be used with a matching coords attribute (except default, which ignores coords).
  • The parent <img> links the map with usemap="#mapName".
  • Include meaningful alt on each area for accessibility.
  • If shape is omitted, browsers treat the area as rect.

💎 Values

The shape attribute accepts four keyword values. Each determines how to interpret coords:

  • rect — Rectangle. coords="x1,y1,x2,y2" (top-left and bottom-right corners).
  • circle — Circle. coords="cx,cy,r" (center x, center y, and radius in pixels).
  • poly — Polygon. coords="x1,y1,x2,y2,..." (pairs of vertex coordinates).
  • default — Entire remaining image not covered by other areas. No coords needed.
shape-values.html
<map name="exampleMap">
  <area shape="rect" coords="0,0,50,50" href="a.html" alt="Area 1">
  <area shape="circle" coords="100,100,50" href="b.html" alt="Area 2">
  <area shape="poly" coords="200,0,250,50,200,100" href="c.html" alt="Area 3">
  <area shape="default" href="fallback.html" alt="Rest of image">
</map>

Note: For circle, the radius is the third number in coords—there is no separate radius attribute on <area>.

⚡ Quick Reference

shape valuecoords formatExample
rectx1, y1, x2, y2coords="10,20,110,120"
circlecx, cy, radiuscoords="150,80,50"
polyx1,y1, x2,y2, …coords="0,0,50,0,25,40"
default(none)Covers unmapped pixels
Applicable element<area>Inside <map>
JavaScriptarea.shape = "rect"Update coords too

Applicable Elements

ElementSupported?Notes
<area>YesPrimary and intended use
<map>NoContainer; put shape on child areas
<img>NoUses usemap to link the map
<a>NoAreas behave like links via href

shape vs coords vs usemap

AttributeOn elementRole
usemap<img>Links image to a named map (#mapName)
shape<area>Defines geometry type (rect, circle, poly, default)
coords<area>Numeric positions interpreted by shape
href<area>Destination when the region is activated

Examples Gallery

Image map with rect, circle, and poly areas, plus dynamic area.shape updates in JavaScript.

👀 Live Preview

Clickable image map with three shaped regions (links log to console on click):

Demo image with clickable map regionsLeft rectangleCenter circleRight polygon

Left: rect · Center: circle · Right: poly

Example — rect, circle, and poly Areas

A complete image map with three shaped hotspots:

shape.html
<img src="diagram.png" alt="Example diagram" usemap="#exampleMap">

<map name="exampleMap">
  <area shape="rect" coords="0,0,50,50" href="destination1.html" alt="Clickable area 1">
  <area shape="circle" coords="100,100,50" href="destination2.html" alt="Clickable area 2">
  <area shape="poly" coords="200,0,250,50,200,100" href="destination3.html" alt="Clickable area 3">
</map>
Try It Yourself

How It Works

Each <area> declares its geometry with shape and coords. The browser hit-tests clicks against those regions and follows the matching href.

Example — default Fallback Region

Link any unmapped pixels with shape="default":

shape-default.html
<map name="navMap">
  <area shape="rect" coords="10,10,90,40" href="/home" alt="Home button">
  <area shape="default" href="/overview" alt="Full diagram">
</map>
Try It Yourself

How It Works

default is a catch-all for pixels not inside any other defined area. Use only one default area per map.

Dynamic Values with JavaScript

Update shape and coords when regions need to change at runtime:

dynamic-shape.html
<area id="dynamicArea" coords="0,0,40,40" href="#" alt="Dynamic region">

<script>
  var area = document.getElementById("dynamicArea");
  area.shape = "rect";
  area.coords = "50,50,100,100";
</script>
Try It Yourself

How It Works

HTMLAreaElement.shape reflects the attribute. When changing shape type, always update coords to match the new geometry rules.

♿ Accessibility

  • Meaningful alt on every area — Describe what the hotspot links to, not just “clickable area.”
  • Descriptive img alt — The image itself needs alt text summarizing the whole diagram.
  • Keyboard access — Image map areas are focusable links; ensure tab order makes sense.
  • Consider responsive alternatives — Fixed pixel coords do not scale; for mobile-first sites, a list of links or SVG may be more accessible.
  • Avoid tiny hotspots — Small click targets are hard for motor-impaired users; keep regions generously sized.

🧠 How shape Works

1

img links map with usemap

Connects image to areas.

Markup
2

area defines shape + coords

rect, circle, poly, default.

Geometry
3

User clicks inside region

Browser hit-tests coords.

Interaction
=

Navigate to href

One image, many links.

Browser Support

The shape attribute on <area> is supported in all modern browsers as part of the HTML image map feature.

HTML5 · Fully supported

Universal image map shapes

All major browsers support rect, circle, poly, and default on area elements.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
shape on <area> 99% supported

Bottom line: Image maps work reliably; plan for responsive layouts since coords are pixel-based.

💡 Best Practices

✅ Do

  • Match shape to the visual region (rect, circle, or poly)
  • Keep coords accurate to the image pixels
  • Add descriptive alt on every <area>
  • Test clicks in multiple browsers and screen sizes
  • Use default for a sensible fallback link when appropriate

❌ Don’t

  • Put shape on <img> instead of <area>
  • Use a separate radius attribute for circles (use coords)
  • Overlap areas without a clear purpose
  • Rely on image maps alone for critical mobile navigation
  • Omit alt text on hotspots

Conclusion

The shape attribute is a valuable tool for creating interactive image maps in HTML. By pairing it with accurate coords and meaningful links, you can turn a single image into multiple navigation targets.

Choose rect, circle, poly, or default based on each region’s geometry, test thoroughly, and consider responsive alternatives when fixed coordinates are not enough for your layout.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about shape

Bookmark these before your next image map.

5
Core concepts
02

rect

Four coords

Value
03

circle

cx, cy, r

Value
🔴 04

poly

Vertex pairs

Value
🔗 05

+ coords

Always together

Pair

❓ Frequently Asked Questions

It defines the geometry of a clickable hotspot on an image map: rectangle, circle, polygon, or default fallback region.
<area> elements inside <map>, linked from an <img usemap>.
coords="centerX,centerY,radius" — three numbers. The radius is part of coords, not a separate HTML attribute.
A catch-all region for any part of the image not covered by other areas. Typically one per map.
Yes. Set areaElement.shape and update areaElement.coords to match the new geometry.
Yes for diagrams and legacy layouts, but responsive sites often prefer SVG or separate links because coords are fixed pixels.

Build interactive image maps

Practice rect, circle, and poly hotspots in the Try It editor.

Try image map example →

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.

5 people found this page helpful