👀 Live Preview
Click the HTML or CSS regions on this navigation diagram:


The coords attribute is used in HTML to define the coordinates of clickable areas within an image map. It belongs on the <area> element and works together with the shape attribute to describe where each hotspot sits on the associated image.
Four corner values.
Center + radius.
Vertex pairs.
Image map setup.
JS updates.
Describe hotspots.
coordsThe primary purpose of the coords attribute is to provide the position and size of a clickable region within an image. This is essential when creating image maps, where different parts of one image link to different destinations.
shape and usemapcoords alone is not enough. Each <area> needs a shape value, and the parent <img> must reference the <map> with usemap="#map-name".
Place coords on an <area> inside a <map>:
<img src="diagram.png" alt="Site map" usemap="#site-map">
<map name="site-map">
<area shape="rect" coords="0,0,100,100" href="/home" alt="Home">
</map>coords with a matching shape attribute on the same <area>.10,10,100,100 and 10, 10, 100, 100 both work.alt on every <area> for accessibility.The coords format depends on the shape of the clickable area:
shape="rect")Use four values — x1, y1, x2, y2 — for the top-left and bottom-right corners of the rectangle:
<area shape="rect" coords="left, top, right, bottom" href="destination.html" alt="Description">shape="circle")Use three values — x, y, radius — for the center point and radius:
<area shape="circle" coords="x, y, radius" href="destination.html" alt="Description">shape="poly")Provide pairs of x, y values for each vertex. You need at least three points to form a polygon:
<area shape="poly" coords="x1, y1, x2, y2, x3, y3, ..." href="destination.html" alt="Description">| shape | coords format | Meaning |
|---|---|---|
rect | x1,y1,x2,y2 | Top-left and bottom-right corners |
circle | x,y,r | Center x, center y, radius |
poly | x1,y1,x2,y2,... | Each vertex of the polygon |
| JavaScript | area.coords = "150,80,50" | Update hotspot at runtime |
| Related attrs | shape, href, alt | Required companions on area |
| Image link | usemap="#map-name" | On img, references map |
| Element | Supported? | Notes |
|---|---|---|
<area> | Yes | Primary element for coords |
<map> | Container | Groups <area> elements; no coords here |
<img> | Related | Uses usemap, not coords |
<div>, <a> | No | Use CSS or normal links instead |
| Attribute | Role | Example |
|---|---|---|
shape | Declares geometry type | rect, circle, poly |
coords | Numbers for that shape | 0,0,100,100 for rect |
href | Destination URL | /about |
alt | Hotspot description | About page |
Full image map with multiple shapes and a JavaScript coords update.
Click the HTML or CSS regions on this navigation diagram:

Here’s an example of using the coords attribute within an image map with rect, circle, and poly shapes:
<img src="diagram.png" alt="Clickable Image" usemap="#imageMap">
<map name="imageMap">
<area shape="rect" coords="10, 10, 100, 100" href="destination1.html" alt="Area 1">
<area shape="circle" coords="150, 80, 50" href="destination2.html" alt="Area 2">
<area shape="poly" coords="220, 30, 300, 80, 250, 150" href="destination3.html" alt="Area 3">
</map>In this example, three clickable areas are defined within the image using different shape values and matching coords formats. Each area also needs an href and descriptive alt text.
You can dynamically set the coords attribute using JavaScript. This is useful when you need to adjust clickable areas based on responsive layouts or user interactions:
<area id="dynamicArea" shape="circle" href="/about" alt="About">
<script>
// Dynamically set coords for a circular area
document.getElementById("dynamicArea").coords = "200, 120, 80";
</script>In this script, the coords property is set on an <area> with id dynamicArea, defining a circle with center (200, 120) and radius 80. Assign a comma-separated string; the browser parses it according to the area’s shape.
Add usemap="#name" on the img element.
Set shape and coords on each area inside map.
Clicks inside coords regions activate the area href.
One image links to many destinations through precise hotspots.
The coords attribute on <area> elements is supported in all modern browsers. Image maps have been part of HTML for decades.
All major browsers honor rect, circle, and poly coords on area elements.
Bottom line: Image maps with coords work reliably; test hotspot alignment if the image is scaled with CSS.
alt attribute) for each clickable area.The coords attribute plays a crucial role in creating interactive image maps in HTML. By understanding how coordinate formats differ for rect, circle, and poly shapes, you can enhance the interactivity and navigation of your web pages.
For simple diagrams and navigation graphics, image maps remain a lightweight option. For highly responsive layouts, consider whether SVG or positioned links better suit your design — but when you use <map> and <area>, coords is how you define each clickable region.
coordsBookmark these before building an image map.
coords lives here.
ScopeThree formats.
ShapesLink image.
SetupJS string.
ScriptDescribe links.
A11ycoords is used on <area> elements inside a <map>. The image links to the map with usemap, not with coords directly.areaElement.coords = "150,80,50" to change the hotspot. The browser interprets the string based on the area’s shape.Practice rect, circle, poly, and JavaScript coords examples in the Try It editor.
5 people found this page helpful