<area>

A clickable region of an image map: a rectangle, circle, or polygon with its own address.

Display
invisible (acts as an image region)
Closing tag
None, void element
Permitted content
None, empty element
On this page

Example

#
HTML
<img
  src="/collections/covers/python-czy-javascript.webp"
  alt="Two desks: on the left a monitor with charts, on the right a laptop with a web page design"
  width="360"
  height="240"
  usemap="#devices"
>
<map name="devices">
  <area shape="rect" coords="52,72,152,128" href="/en/docs/python" alt="Monitor with charts: Python documentation">
  <area shape="rect" coords="210,80,300,144" href="/en/docs/javascript" alt="Laptop with a web page design: JavaScript documentation">
</map>
Preview

The regions are invisible. Hover over the monitor or the laptop, or move through them with the Tab key.

Definition and usage

#

The <area> element defines one clickable part of an image inside a <map>. It works like an <a> link: it has an href attribute, can open the address in a new tab (target), or download a file (download). It is an empty element.

You choose the shape with the shape attribute, and give the position in coords as numbers in pixels measured from the top left corner of the image. A rectangle is described by two corners, a circle by its center and radius, and a polygon by consecutive vertices.

A region with href must have alt, because it is the only name a screen reader can read. The region itself is invisible: it is revealed only by the cursor change or the focus outline when you reach it with the Tab key.

Syntax

#
Syntax
<area shape="rect" coords="x1,y1,x2,y2" href="…" alt="…">

Attributes

#
  • shape

    rect | circle | poly | default

    The shape of the region: rect is a rectangle (the default), circle a circle, poly any polygon, and default the whole image apart from the other regions. The example shows a circle on the poster and a polygon outlining the laptop.
  • coords

    comma-separated list of numbers

    Coordinates in pixels. For rect these are the top left and bottom right corners (x1,y1,x2,y2), for circle the center and radius (x,y,r), and for poly consecutive vertices (x1,y1,x2,y2,…).
  • href

    URL

    The address the region leads to. Without href the region is not a link.
  • alt

    text

    The alternative text of the region, required when the region has href. It should say where the click leads.
  • target / download / rel

    as in the `<a>` element

    They work the same as in a link: target="_blank" opens the address in a new tab, download downloads the file instead of opening it, and rel describes the relationship with the target.

The element also supports all global attributes, such as class, id, style and hidden.

Attributes in practice

#

shape

rect | circle | poly | default

The shape of the region: rect is a rectangle (the default), circle a circle, poly any polygon, and default the whole image apart from the other regions. The example shows a circle on the poster and a polygon outlining the laptop.

HTML
<img
  src="/collections/covers/python-czy-javascript.webp"
  alt="Two desks: on the left a monitor with charts, on the right a laptop with a web page design"
  width="360"
  height="240"
  usemap="#shapes"
>
<map name="shapes">
  <area shape="circle" coords="250,36,12" href="/en/collections" alt="Poster on the wall: article collections">
  <area shape="poly" coords="214,83,287,83,287,128,296,140,212,140" href="/en/docs/html" alt="Laptop: HTML documentation">
</map>
Preview

Hover over the round shape on the poster or over the laptop.

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • <area> works only inside a <map>, and the image must point to the map with the usemap attribute.
  • The coordinates refer to the image at the size displayed on the page, not the original file. If you change the image’s width, recalculate coords too.

Related entries

#

Spotted a mistake or missing an example? Write to us.