HTML <area> tagS2C Home   « HTML <area> tag

Definition

The <area> tag is a self closing tag used within the <map></map> element to define the clickable areas.

Example


<p>Click on an object in the picture to interact with it.</p>
<img src="https://server2client.com/images/enhancedimagesmall.jpg"
     alt="interaction" 
     width="300" 
     height="200" 
     usemap="#lesson3">
<map id="lesson3" name="lesson3">
  <area shape="rect"
        alt="paper"
        coords="10,10,156,190" 
        href="javascript:alert('blank sheet of paper');">
  <area shape="circle"
        alt="apple"
        coords="235,45,50" 
        href="https://server2client.com/pages/apple.html">
  <area shape="circle"
        alt="tomato"
        coords="230,145,25" 
        href="https://server2client.com/pages/tomato.html">
</map>

Click on an object in the picture to interact with it.

interaction paper apple tomato

Required Attributes

coords - specifies the coordinates of the area and should be used in conjunction with the shape attribute.


<area alt="tomato" shape="rect" coords="0,0,12,15">

shape - specifies the shape of the area and should in conjunction with the coords attribute.


<!-- Valid values are rect, circle and poly, defaults to whole area. -->
<area alt="tomato" shape="rect"> coords="0,0,12,15">

Optional Attributes

alt - specifies an alternate text for the map area; required if the href attribute is present.


<area alt="tomato">

download specifies the file to download when linked is clicked.


<area alt="tomato" download="someFileName">

href specifies the target URL to link to.


<area alt="tomato" href="https://server2client.com/images/chickenpiesmall.jpg">

hreflang specifies the language code of target URL to link to.


<area alt="tomato" hreflang="en">

rel - specifies a space-separated list of relationships between the current resource and destination URL.

Only used when the href attribute is present.


<!-- Valid values are alternate, author, bookmark, help, license -->
<!-- next, nofollow, noreferrer, prefetch, prev, search and tag -->
<area alt="tomato" rel="author license">

target - specifies where to open the linked resource.


<!-- Valid values are _blank, _parent, _self, _top or framename -->
<area alt="tomato" target="_self">

type - specifies the MIME type of the linked resource.

Only used when the href attribute is present.


<area alt="tomato" text/html>

Global Attributes

Common

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<area alt="tomato" class="className">

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<area alt="tomato" id="idName">

style - specifies an inline style for the element allowing you to apply the style to the content.


<area alt="tomato" style="color:red;text-align:left">

tabindex - specifies the tab order of the element.


<area alt="tomato" tabindex="2">

title - specifies extra information about the content.


<area alt="tomato" title="Title Information">

Keyboard

accesskey - specifies a keyboard shortcut to associate with the element.


<area alt="tomato" accesskey="aKeyValue">;

tabindex - specifies a tab order for the element.


<area alt="tomato" tabindex="someNumber">

Language

dir - specifies the directional flow of the content.


<area alt="tomato" dir="ltr"> <!-- The text will flow from left to right -->
<area alt="tomato" dir="rtl"> <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<area alt="tomato" lang="en">

spellcheck - specifies whether the element is to have its spelling checked.


<!-- Valid values are true and  false - default is inherited / browser specific. -->
<area alt="tomato"spellcheck="true">

translate - specifies whether the content of the element can be translated.


<!-- Valid values are yes and  no - default is yes. -->
<area alt="tomato" translate="no"> 

Miscellaneous

contenteditable - specifies whether the content of the element is editable.


<!-- Valid values are true and  false - default is inherited. -->
<area alt="tomato" contenteditable="false"> 

draggable - specifies whether the the element is draggable.

Only text selections, images, and links can be dragged.


<!-- Valid values are true and  false - default is browser specific. -->
<area alt="tomato" draggable="true">

hidden - specifies whether the element is not yet, or no longer, relevant.


<!-- Valid values are an empty string or hidden -->
<area alt="tomato" hidden> 
<area alt="tomato" hidden="hidden"> 

Event Attributes

Document

onabort - The JavaScript code to be run on abort.


<area alt="tomato" onabort="go()">   <!-- Executes the go() function -->

onerror - The JavaScript code to be run when an error occurs when the file is being loaded.


<area alt="tomato" onerror="go()">   <!-- Executes the go() function -->

onload - The JavaScript code to be run when the document is loaded.


<body onload="go()">   <!-- Executes the go() function -->

onresize - The JavaScript code to be run when the browser window is resized.


<area alt="tomato" onresize="go()">   <!-- Executes the go() function -->

onscroll - The JavaScript code to be run when the scrollbar of an element is being scrolled.


<area alt="tomato" onscroll="go()">   <!-- Executes the go() function -->

onunload - The JavaScript code to be run once a page has unloaded or the browser window has been closed.


<area alt="tomato" onunload="go()">   <!-- Executes the go() function -->

Document Element

oncopy - The JavaScript code to be run when the user copies the content of an element.


<area alt="tomato" oncopy="go()">   <!-- Executes the go() function -->

oncut - The JavaScript code to be run when the user cuts the content of an element.


<area alt="tomato" oncut="go()">   <!-- Executes the go() function -->

onpaste - The JavaScript code to be run when the user pastes some content into an element.


<area alt="tomato" onpaste="go()">   <!-- Executes the go() function -->

Drag and Drop

ondrag - The JavaScript code to be run when an element is dragged.


<area alt="tomato" ondrag="go()">   <!-- Executes the go() function -->

ondragend - The JavaScript code to be run when an element has stopped being dragged.


<area alt="tomato" ondragend="go()">   <!-- Executes the go() function -->

ondragenter - The JavaScript code to be run when an element has been dragged to a valid drop target.


<area alt="tomato" ondragenter="go()">   <!-- Executes the go() function -->

ondragleave - The JavaScript code to be run when an element leaves a valid drop target.


<area alt="tomato" ondragleave="go()">   <!-- Executes the go() function -->

ondragover - The JavaScript code to be run when an element is being dragged over a valid drop target.


<area alt="tomato" ondragover="go()">   <!-- Executes the go() function -->

ondragstart - The JavaScript code to be run at the start of a drag operation.


<area alt="tomato" ondragstart="go()">   <!-- Executes the go() function -->

ondrop - The JavaScript code to be run when dragged element is being dropped.


<area alt="tomato" ondrop="go()">   <!-- Executes the go() function -->

Form

onchange - The JavaScript code to be run when object changed and attempt to leave field.


<area alt="tomato" onchange="go()">   <!-- Executes the go() function -->

oncontextmenu - The JavaScript code to be run when a context menu is triggered.


<area alt="tomato" oncontextmenu="go()">   <!-- Executes the go() function -->

onfocus - The JavaScript code to be run when the element gets focus.


<area alt="tomato" onfocus="go()">   <!-- Executes the go() function -->

oninput - The JavaScript code to be run when an element gets user input.


<area alt="tomato" oninput="go()">   <!-- Executes the go() function -->

oninvalid - The JavaScript code to be run when an element is invalid.


<area alt="tomato" oninvalid="go()">   <!-- Executes the go() function -->

onreset - The JavaScript code to be run when the reset button of a form is clicked.


<area alt="tomato" onreset="go()">   <!-- Executes the go() function -->

onselect - The JavaScript code to be run when some or all of the contents of an object are selected.


<area alt="tomato" onselect="go()">   <!-- Executes the go() function -->

onsubmit - The JavaScript code to be run when a form is submitted.


<area alt="tomato" onsubmit="go()">   <!-- Executes the go() function -->

Keyboard

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<area alt="tomato" onkeydown="go()">   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<area alt="tomato" onkeypress="go()">   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<area alt="tomato" onkeyup="go()">   <!-- Executes the go() function -->

Media

oncanplay - The JavaScript code to be run when a file has buffered enough so it is ready to start playing.


<area alt="tomato" oncanplay="go()">   <!-- Executes the go() function -->

oncanplaythrough - The JavaScript code to be run when a file can be played all the way to the end without further need of buffering.


<area alt="tomato" oncanplaythrough="go()">   <!-- Executes the go() function -->

oncuechange - The JavaScript code to be run when the cue changes when using the track element.


<body oncuechange="go()">   <!-- Executes the go() function -->

ondurationchange - The JavaScript code to be run when the length of the media is changed.


<area alt="tomato" ondurationchange="go()">   <!-- Executes the go() function -->

onemptied - The JavaScript code to be run when a media resource element suddenly becomes empty, usually due to an error.


<area alt="tomato" onemptied="go()">   <!-- Executes the go() function -->

onended - The JavaScript code to be run when the media has reach the end.


<area alt="tomato" onended="go()">   <!-- Executes the go() function -->

onloadeddata - The JavaScript code to be run when media data is loaded and playback can start.


<area alt="tomato" onloadeddata="go()">   <!-- Executes the go() function -->

onloadedmetadata - The JavaScript code to be run when metadata has been loaded.


<body onloadedmetadata="go()">   <!-- Executes the go() function -->

onloadstart - The JavaScript code to be run when the media resource has started loading.


<area alt="tomato" onloadstart="go()">   <!-- Executes the go() function -->

onpause - The JavaScript code to be run when the media resource has been paused.


<area alt="tomato" onpause="go()">   <!-- Executes the go() function -->

onplay - The JavaScript code to be run when the media resource starts playback.


<area alt="tomato" onplay="go()">   <!-- Executes the go() function -->

onplaying - The JavaScript code to be run when playback has already begun.


<area alt="tomato" onplaying="go()">   <!-- Executes the go() function -->

onprogress - The JavaScript code to be run when the browser is fetching the media data.


<body onprogress="go()">   <!-- Executes the go() function -->

onratechange - The JavaScript code to be run when the playback rate changes.


<area alt="tomato" onratechange="go()">   <!-- Executes the go() function -->

onseeked - The JavaScript code to be run when the seeking attribute is set to false indicating that seeking has finished.


<area alt="tomato" onseeked="go()">   <!-- Executes the go() function -->

onseeking - The JavaScript code to be run hen the seeking attribute is set to true indicating that seeking is currently active.


<area alt="tomato" onseeking="go()">   <!-- Executes the go() function -->

onstalled - The JavaScript code to be run when the browser is unable to continue fetching media data.


<area alt="tomato" onstalled="go()">   <!-- Executes the go() function -->

onsuspend - The JavaScript code to be run when media data has stopped before being completely loaded.


<body onsuspend="go()">   <!-- Executes the go() function -->

ontimeupdate - The JavaScript code to be run when the media resources current playback position has changed.


<area alt="tomato" ontimeupdate="go()">   <!-- Executes the go() function -->

onvolumechange - The JavaScript code to be run when the volume has changed or been muted.


<area alt="tomato" onvolumechange="go()">   <!-- Executes the go() function -->

onwaiting - The JavaScript code to be run when the media resource has paused but is expected to resume.


<area alt="tomato" onwaiting="go()">   <!-- Executes the go() function -->

Mouse

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<area alt="tomato"  onclick="go()">   <!-- Executes the go() function -->

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<area alt="tomato"  ondblclick="go()">   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<area alt="tomato"  onmousedown="go()">   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<area alt="tomato"  onmousemove="go()">   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<area alt="tomato"  onmouseout="go()">   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<area alt="tomato"  onmouseover="go()">   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<area alt="tomato"  onmouseup="go()">   <!-- Executes the go() function -->

onwheel - The JavaScript code to be run when the mouse wheel rolls up or down over an element.


<area alt="tomato" onwheel="go()">   <!-- Executes the go() function -->

Window

NONE

go to home page Homepage go to top of page Top