HTML coords Attribute

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

Definition and Usage

The coords attribute on an <area> sets the pixel coordinates of a clickable hotspot in an image map. Pair it with shape (rect, circle, or poly). Values are CSS pixels from the image’s top-left corner.

Put areas inside a <map>, and link the <img> with usemap="#map-name". When the area has href, also provide meaningful alt text.

Baseline · Widely available.

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

Not with shape="default".

The default shape covers the whole image. Do not use coords when shape is default.

HTML Syntax

syntax.html
<area shape=" rect" coords="x1,y1,x2,y2" …>

Replace the shape and coords list for circle (x,y,r) or poly (x1,y1,…). Origin is always the image’s top-left.

Attribute Values

Format depends on the matching shape:

shapecoords formatTry it
rectx1,y1,x2,y2 — top-left and bottom-right cornersTry it
circlex,y,radius — center and radiusTry it
polyx1,y1,x2,y2,… — vertex pairs (at least 3)Try it
defaultOmit coords — remaining image areaTry it

Live Preview

Switch the hotspot shape. Click the image region that matches the active shape (demo links stay on this page).

Click the logo hotspot. The note below shows the live coords string.

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 (rect)

Four numbers: top-left x1,y1 and bottom-right x2,y2.

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" tells the browser to expect four coordinates.
  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 (circle)

Three numbers: 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" expects exactly three values.
  2. 64,64 is the center of a 128×128 image.
  3. 55 is the radius in CSS pixels (corners stay outside the circle).
  4. Clicks outside the circle do not activate this area.

Example 3 — Polygon (poly)

List every vertex as x,y pairs. At least three pairs are required.

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" reads an even-length list of numbers.
  2. Three corners form a triangle pointing up from the bottom edge.
  3. Closing is automatic if the first and last points differ.
  4. Order of vertices follows the outline around the region.

Edge Cases & Pitfalls

Coords are measured on the image’s natural size — scaling and missing alt text cause common bugs.

scale

CSS resizing drifts hotspots

If you change the image’s displayed size with CSS, coords stay in the original pixel space. Prefer matching width/height attributes, or recalculate coords in script.

shape

Match shape and coords length

rect needs 4 numbers, circle needs 3, poly needs an even count of at least 6. Wrong length = broken or empty hotspot.

a11y

alt is required with href

Each linked area needs alt that describes the choice (like link text). Order areas in source to match visual reading order for keyboard users.

default

No coords on default

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

JS

Update with area.coords

Assign a comma-separated string, e.g. area.coords = "64,64,40", when you need to move or resize a hotspot at runtime.

Browser Support

coords is an HTML attribute on <area> for image maps in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

coords

Widely available with HTML image maps. Support for rect, circle, and poly is consistent; test alignment when images are responsive.

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 All modern
Full support
Internet Explorer All versions
Supported
coords Widely supported

Bottom line: Safe to use for classic image maps. Prefer SVG or CSS overlays when you need responsive, maintainable hotspots.

Key Takeaways

  • Role: pixel coordinates for an <area> hotspot.
  • Pairing: always match shape (rect / circle / poly).
  • Wiring: <map> + usemap on <img>.
  • Caution: omit coords for default; watch CSS scaling.

One line: coords draws the hotspot; shape chooses the geometry.

Frequently Asked Questions

On an area element inside a map, coords lists the hotspot’s CSS-pixel coordinates. The format depends on shape: rect uses four numbers, circle uses three, and poly uses pairs of x,y values.
Only area (inside map). The image links to the map with usemap. Do not put coords on img.
shape="rect" uses coords="x1,y1,x2,y2" — top-left and bottom-right corners in CSS pixels from the image’s top-left.
circle uses x,y,radius (center and radius). poly uses x1,y1,x2,y2,... for each vertex (at least three pairs). The browser closes the polygon if needed.
No. shape="default" covers the whole image (minus other areas). Omit coords in that case.
Image maps with coords are Baseline widely available and work in all modern browsers. Hotspots can misalign if the image is scaled with CSS without matching coordinates.

Next: crossorigin

Control CORS for images, scripts, video, and audio.

crossorigin 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