HTML <area> href Attribute

The href attribute on an <area> tag redirects to the specified URL when the area is clicked. This URL can be an internal or external URL, and also JavaScript.

Example

#

An href attribute on 3 <area> tags.
The attributes invoke JavaScript which displays the name of the area that was clicked.

Computer Screen Keyboard Mouse
<img src="/img/html/computer-map.png" alt="Computer" usemap="#computermap">

<map name="computermap">
  <area shape="rect" coords="253,142,16,2" alt="Screen" 
        href="javascript:alert('Screen was clicked');">
  <area shape="rect" coords="262,218,0,156" alt="Keyboard" 
        href="javascript:alert('Keyboard was clicked');">
  <area shape="circle" coords="267,234,22" alt="Mouse" 
        href="javascript:alert('Mouse was clicked');">
</map>

Note: In this example an alert box is displayed rather than redirecting to a URL.


Using href

The href attribute specifies the URL of the target page or resource.

It accepts any of these URL forms:

  • absolute URL - link to a page on an external website or domain (e.g. https://wikipedia.com)
  • relative URL - link to an internal page on the same domain (with a shorter url)
  • anchor URL - link to an anchored section within the same page (with the # notation)

Syntax

<area href="URL" />

Values

#

Value Description
URL URL or path of the linked resource or page.

Browser support

Here is when href support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <area>
Guides