🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

<area>

AI & DATA SCIENCE // area-tag

The <area> element defines a single clickable, linkable region within a <map>, specified by a shape and coordinate set.

Syntax

<area shape="circle" coords="50,50,40" href="/page" alt="Description">

Deep Dive Course

**`<area>`** is a void element, always nested inside a `<map>`, and requires **`shape`** (`rect`, `circle`, `poly`, or `default` for the entire remaining image area) plus matching **`coords`** (pixel values whose meaning depends on the shape — x1,y1,x2,y2 for a rectangle; x,y,radius for a circle; a flat list of x,y pairs for a polygon). Like `<a>`, it needs **`href`** for the destination and should include **`alt`** text describing that specific region for accessibility.

1Understanding <area>

`<area>` is a void element, always nested inside a <map>, and requires `shape` (rect, circle, poly, or default for the entire remaining image area) plus matching `coords` (pixel values whose meaning depends on the shape — x1,y1,x2,y2 for a rectangle; x,y,radius for a circle; a flat list of x,y pairs for a polygon). Like <a>, it needs `href` for the destination and should include `alt` text describing that specific region for accessibility.

💡

For shape="poly", coords is a flat, comma-separated list of alternating x,y pairs tracing the polygon's vertices in order — getting this list right for a complex shape usually requires an image-map-generating tool rather than hand-calculating coordinates.

editor.html
<map name="buttons">
  <area shape="rect" coords="0,0,50,50" href="/home" alt="Home button">
  <area shape="rect" coords="60,0,110,50" href="/settings" alt="Settings button">
</map>
localhost:3000

2Practical Example

Here is a real-world application of <area> showing how it is used in production HTML.

editor.html
<!-- A triangular polygon region -->
<area shape="poly" coords="50,0,100,100,0,100" href="/triangle-zone" alt="Triangular zone">
localhost:3000

3Best Practices

Follow these guidelines when working with <area>:

1. Match the coords format to the chosen shape exactly (rect, circle, poly each expect a different coordinate layout)

2. Always include alt text describing what that specific clickable region represents

3. Use shape="default" for a catch-all region covering whatever isn't covered by other more specific areas

⚠️

Tip: For shape="poly", coords is a flat, comma-separated list of alternating x,y pairs tracing the polygon's vertices in order — getting this list right for a complex shape usually requires an image-map-generating tool rather than hand-calculating coordinates.

editor.html
<map name="buttons">
  <area shape="rect" coords="0,0,50,50" href="/home" alt="Home button">
  <area shape="rect" coords="60,0,110,50" href="/settings" alt="Settings button">
</map>
localhost:3000

Examples

Example 01Basic Usage
<map name="buttons">
  <area shape="rect" coords="0,0,50,50" href="/home" alt="Home button">
  <area shape="rect" coords="60,0,110,50" href="/settings" alt="Settings button">
</map>
Example 02Advanced Example
<!-- A triangular polygon region -->
<area shape="poly" coords="50,0,100,100,0,100" href="/triangle-zone" alt="Triangular zone">

Best Practices

  • Match the coords format to the chosen shape exactly (rect, circle, poly each expect a different coordinate layout)
  • Always include alt text describing what that specific clickable region represents
  • Use shape="default" for a catch-all region covering whatever isn't covered by other more specific areas

Interview Question

How does the meaning of the coords attribute change depending on the shape attribute's value?

Hint: Think about rect, circle, and poly each needing fundamentally different numbers to describe their geometry.

For shape="rect", coords is x1,y1,x2,y2 — the top-left and bottom-right corners of the rectangle. For shape="circle", coords is x,y,radius — the center point and radius. For shape="poly", coords is a flat list of alternating x,y coordinate pairs tracing every vertex of the polygon in order, and can be as long as needed for complex shapes. Because the format is entirely shape-dependent, the two attributes must always be set together consistently.

Exercises

EasyPractice using <area> in a real scenario.
View Solution
<map name="buttons">
  <area shape="rect" coords="0,0,50,50" href="/home" alt="Home button">
  <area shape="rect" coords="60,0,110,50" href="/settings" alt="Settings button">
</map>

Frequently Asked Questions

How does the meaning of the coords attribute change depending on the shape attribute's value?

For shape="rect", coords is x1,y1,x2,y2 — the top-left and bottom-right corners of the rectangle. For shape="circle", coords is x,y,radius — the center point and radius. For shape="poly", coords is a flat list of alternating x,y coordinate pairs tracing every vertex of the polygon in order, and can be as long as needed for complex shapes. Because the format is entirely shape-dependent, the two attributes must always be set together consistently.

Related Functions

map-taga-tag