HTML Tags – Area Tag


What is an <area> tag in HTML ?

HTML <area> tag is used to create an area inside the image map.

What is an image map ?

Image map is an image with clickable areas.

Image map allows geometric areas on an image to be associated with hypertext link.

By default the <area> element inside an image map that has predefined clickable areas.

How <area> is implemented ?

HTML <area> tag is used for defining an area in an image map.


<area> elements are always nested inside a <map> tag.

“usemap” attribute in <img> is associated with the <map> element’s name attribute, and creates a relationship between the image and the map.

Syntax :

<img src ="/myImage.png" alt="My Image" usemap ="#my-imgmap">
<map name="my-imgmap">
  <area 
    shape="rect" 
    coords="50,50,100,100" 
    href="/box/" 
    alt="My rectangle box">
</map>

Example :

<!DOCTYPE html>
<html>
<head>
  <title>HTML area tag</title>
</head>
<body>
  <img src="https://secureservercdn.net/192.169.221.188/s30.e0b.myftpupload.com/wp-content/uploads/2020/10/html5-title-cc-1.png" width="300" height="300" alt="CSTechbook" usemap ="#define">
  <map name="define" >
    <area shape ="rect" coords ="0,0,115,90" href ="https://s30.e0b.myftpupload.com/home" alt="croud"/>
    <area shape ="poly" coords ="10,10,162,82,175,100,181,102,175,148,122,146" href ="https://s30.e0b.myftpupload.com/client-side-html-5/" alt="water"/>
  </map>
</body>
</html>

Output :

HTML coding for a website !!!

Click to Learn More about – HTML Tutorial for beginners

<area> Tag Attributes

<area> tag supported following specific attributes.

SnoAttributesValueDescription
1alttextSpecifies the text to identify the render the image.
2hrefurlSpecifies URL link to information about render image.
3target_blank
_parent
_self
_top
Loads the linked document in new window.
Loads the linked document in the parent frame.
Loads the linked document in the same window.
Loads the linked document in the top up on same window.
4shaperect
circle
poly
define sharp of specify render image.
5coordscoords_valueSpecifies the coordinates of an image map.

Global Attributes

<area> tag also support global attributes.


SnoAttributesValueDescription
1idunique_nameDeclared unique id for an element.
2classclass_nameDeclared one or more classnames for an element.
3stylestylesCSS inline styles specify an element.
4titletitleSpecify extra details of element contain, this will display as a “tooltip” for an elements.

Event Attributes

<area> tag support following Event attributes.

SnoAttributesValueDescription
1onfocusscriptelement gets focus on object when script tobe run.
2onblurscriptelement lose the focus on object when scrip tobe run.
3onclickscriptclicked on object when script tobe run.
4ondblclickscriptdouble click on object when script tobe run.
5onkeydownscriptkey is pressed when script tobe run.
6onkeypressscriptkey is pressed over element then released when script tobe run.
7onkeyupscriptkey is released over element when script tobe run.
8onmousedownscriptmouse button was pressed over an element when script tobe run.
9onmouseoutscriptmouse pointer release over an element when script tobe run.
10onmousemovescriptrun mouse pointer moved when script tobe run.
11onmouseoverscriptrun mouse pointer move over when script tobe run.
12onmouseupscriptmouse button is released when script tobe run.

Browser Compatibility

SnoBrowserSupport
1ChromeYes
2FirefoxYes
3EdgeYes
4OperaYes
5SafariYes
6Internet ExplorerYes