HTML5 Reference

HTML <map> tag

Definition

The <map> tag is used to define to define a client-side image map which is an image that has clickable areas.

The tag is used in conjunction with the <area> and/or <img> tags to specify clickable areas of an image.

Example


<p>Click on an object in the picture to interact with it.</p>
<img src="../../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="../../pages/apple.html">
  <area shape="circle"
        alt="tomato"
        coords="230,145,25" 
        href="../../pages/tomato.html">
</map>

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

interaction paper apple tomato

Attributes

The following attributes can be used with the <map> tag.


<map> Specific Attributes
Attribute Value Description Example
namevalueSpecifies a name for the map.

When the name attribute is used and the id attribute is also present it must contain the same value as the name attribute.

<map id="mapone" name="mapone">Map content</map>
<map> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<map class="name">Map content</map>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<map id="name">Map content</map>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<map style="color:red;">Map content</map>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<map title="Content info">Map content</map>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<map accesskey="a">Map content</map>
tabindexSpecifies a tab order for the element.

<map tabindex="1">Map content</map>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<map dir="ltr">Map content</map>
<!-- The text will flow from right to left -->
<map dir="rtl">Map content</map>
langSpecifies a language code for the content of the element.

<map lang="en">Map content</map>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<map spellcheck="true">Map content</map> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<map translate="no">Map content</map> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<map contenteditable="true">Map content</map> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<map draggable="true">Map content</map>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<map hidden>Map content</map> 
<map hidden="hidden">Map content</map> 
<map> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<map oncopy="go()">Map content</map> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<map oncut="go()">Map content</map>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<map onpaste="go()">Map content</map>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<map ondrag="go()">Map content</map>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<map ondragend="go()">Map content</map>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<map ondragenter="go()">Map content</map>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<map ondragleave="go()">Map content</map>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<map ondragover="go()">Map content</map>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<map ondragstart="go()">Map content</map>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<map ondrop="go()">Map content</map>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<map onblur="go()">Map content</map>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<map onchange="go()">Map content</map>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<map oncontextmenu="go()">Map content</map>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<map onfocus="go()">Map content</map>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<map oninput="go()">Map content</map>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<map oninvalid="go()">Map content</map>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<map onreset="go()">Map content</map>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<map onselect="go()">Map content</map>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<map onsubmit="go()">Map content</map>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<map onkeydown="go()">Map content</map>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<map onkeypress="go()">Map content</map>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<map onkeyup="go()">Map content</map>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<map onabort="go()">Map content</map>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<map oncanplay="go()">Map content</map>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<map oncanplaythrough="go()">Map content</map>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<map oncuechange="go()">Map content</map>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<map ondurationchange="go()">Map content</map>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<map onemptied="go()">Map content</map>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<map onended="go()">Map content</map>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<map onloadeddata="go()">Map content</map>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<map onloadedmetadata="go()">Map content</map>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<map onloadstart="go()">Map content</map>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<map onpause="go()">Map content</map>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<map onplay="go()">Map content</map>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<map onplaying="go()">Map content</map>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<map onprogress="go()">Map content</map>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<map onratechange="go()">Map content</map>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<map onseeked="go()">Map content</map>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<map onseeking="go()">Map content</map>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<map onstalled="go()">Map content</map>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<map onsuspend="go()">Map content</map>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<map ontimeupdate="go()">Map content</map>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<map onvolumechange="go()">Map content</map>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<map onwaiting="go()">Map content</map>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<map onclick="go()">Map content</map>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<map ondblclick="go()">Map content</map>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<map onmousedown="go()">Map content</map>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<map onmousemove="go()">Map content</map>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<map onmouseout="go()">Map content</map>>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<map onmouseover="go()">Map content</map>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<map onmouseup="go()">Map content</map>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<map onwheel="go()">Map content</map>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<map onscroll="go()">Map content</map> 
Window - NONE

Relevant HTML Tutorials

HTML Advanced - Image Maps