👀 Live Preview
Clickable image map with three shaped regions (links log to console on click):
Left: rect · Center: circle · Right: poly

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.
Where shape applies.
Rectangle regions.
Round hotspots.
Custom polygons.
Pair with shape.
area.shape API.
shapeThe 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.
shape alone does nothing useful. Every <area> needs matching coords, plus href (or alternative behavior) and descriptive alt text.
Add shape to <area> elements inside a <map> linked from an <img usemap>:
<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><area> elements inside <map>.rect, circle, poly, or default.coords attribute (except default, which ignores coords).<img> links the map with usemap="#mapName".alt on each area for accessibility.shape is omitted, browsers treat the area as rect.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.<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>.
| shape value | coords format | Example |
|---|---|---|
rect | x1, y1, x2, y2 | coords="10,20,110,120" |
circle | cx, cy, radius | coords="150,80,50" |
poly | x1,y1, x2,y2, … | coords="0,0,50,0,25,40" |
default | (none) | Covers unmapped pixels |
| Applicable element | <area> | Inside <map> |
| JavaScript | area.shape = "rect" | Update coords too |
| Element | Supported? | Notes |
|---|---|---|
<area> | Yes | Primary and intended use |
<map> | No | Container; put shape on child areas |
<img> | No | Uses usemap to link the map |
<a> | No | Areas behave like links via href |
shape vs coords vs usemap| Attribute | On element | Role |
|---|---|---|
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 |
Image map with rect, circle, and poly areas, plus dynamic area.shape updates in JavaScript.
Clickable image map with three shaped regions (links log to console on click):
Left: rect · Center: circle · Right: poly
A complete image map with three shaped hotspots:
<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>Each <area> declares its geometry with shape and coords. The browser hit-tests clicks against those regions and follows the matching href.
default Fallback RegionLink any unmapped pixels with shape="default":
<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>default is a catch-all for pixels not inside any other defined area. Use only one default area per map.
Update shape and coords when regions need to change at runtime:
<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>HTMLAreaElement.shape reflects the attribute. When changing shape type, always update coords to match the new geometry rules.
Connects image to areas.
rect, circle, poly, default.
Browser hit-tests coords.
One image, many links.
The shape attribute on <area> is supported in all modern browsers as part of the HTML image map feature.
All major browsers support rect, circle, poly, and default on area elements.
Bottom line: Image maps work reliably; plan for responsive layouts since coords are pixel-based.
shape to the visual region (rect, circle, or poly)coords accurate to the image pixelsalt on every <area>default for a sensible fallback link when appropriateshape on <img> instead of <area>radius attribute for circles (use coords)alt text on hotspotsThe 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.
shapeBookmark these before your next image map.
Image map only
ScopeFour coords
Valuecx, cy, r
ValueVertex pairs
ValueAlways together
Pair<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.areaElement.shape and update areaElement.coords to match the new geometry.Practice rect, circle, and poly hotspots in the Try It editor.
5 people found this page helpful