Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 910007 of <map>

  • Revision slug: Web/HTML/Element/map
  • Revision title: <map>
  • Revision id: 910007
  • Created:
  • Creator: Andrew_Pfeiffer
  • Is current revision? No
  • Comment add mandatory "name" attribute to the example

Revision Content

The HTML <map> element is used with {{HTMLElement("area")}} elements to define an image map (a clickable link area).

Attributes

This element includes the global attributes.

{{htmlattrdef("name")}}
The name attribute gives the map a name so that it can be referenced. The attribute must be present and must have a non-empty value with no space characters. The value of the name attribute must not be a compatibility-caseless match for the value of the name attribute of another map element in the same document. If the id attribute is also specified, both attributes must have the same value.

Examples

<map name="example-map-1">
  <area shape="circle" coords="200,250,25" href="another.htm" />
  <area shape="default" />
</map>

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', 'the-map-element.html#the-map-element', '<map>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'embedded-content-0.html#the-map-element', '<map>')}} {{Spec2('HTML5 W3C')}}  
{{SpecName('HTML4.01', 'struct/objects.html#h-13.6.1', '<map>')}} {{Spec2('HTML4.01')}} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{CompatGeckoDesktop(1.0)}}[1]
{{CompatGeckoDesktop(5.0)}}[2]
{{CompatGeckoDesktop(17.0)}}[3]
{{CompatVersionUnknown}} 1.0 1.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 1.0 {{CompatGeckoMobile(1.0)}}[1]
{{CompatGeckoMobile(5.0)}}[2]
{{CompatGeckoMobile(17.0)}}[3]
{{CompatVersionUnknown}} 1.0 1.0

[1] Starting in Gecko 5.0 {{geckoRelease("5.0")}}, empty maps are no longer skipped over in favor of non-empty ones when matching when in quirks mode. For example, consider the following HTML:

<map></map>
<map>
  <area shape="rect" coords="25,25,75,75" href="#fail">
</map>
<img usemap="#a" src="image.png">

[2] Prior to Gecko 5.0, the {{HTMLElement("img")}} element would have matched to the second, non-empty map. Now it matches against the first one, even though it's empty.

[3] From Firefox 17 the default styling of the <map> HTML element is display: inline; and no more display: block;. This matches the behavior of the other browsers and was already the case in quirks mode.

See also

  • {{HTMLElement("a")}}
  • {{HTMLElement("area")}}

{{HTMLRef}}

Revision Source

<p>The <strong>HTML <code>&lt;map&gt;</code> element</strong> is used with {{HTMLElement("area")}} elements to define an image map (a clickable link area).</p>

<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/HTML/Content_categories">Content categories</a></dfn> <a href="/en-US/docs/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a>, palpable content.</li>
 <li><dfn>Permitted content</dfn> Any <a href="/en-US/docs/HTML/Content_categories#Transparent_content_model">transparent</a> element.</li>
 <li><dfn>Tag omission</dfn> {{no_tag_omission}}</li>
 <li><dfn>Permitted parent elements</dfn> Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Phrasing_content">phrasing content</a>.</li>
 <li><dfn>DOM interface</dfn> {{domxref("HTMLMapElement")}}</li>
</ul>

<h2 id="Attributes">Attributes</h2>

<p>This element includes the <a href="https://developer.mozilla.org/en-US/docs/HTML/Global_attributes">global attributes</a>.</p>

<dl>
 <dt>{{htmlattrdef("name")}}</dt>
 <dd>The name attribute gives the map a name so that it can be referenced. The attribute must be present and must have a non-empty value with no space characters. The value of the name attribute must not be a compatibility-caseless match for the value of the name attribute of another map element in the same document. If the id attribute is also specified, both attributes must have the same value.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<pre class="brush: html">
&lt;map name="example-map-1"&gt;
  &lt;area shape="circle" coords="200,250,25" href="another.htm" /&gt;
  &lt;area shape="default" /&gt;
&lt;/map&gt;
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'the-map-element.html#the-map-element', '&lt;map&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'embedded-content-0.html#the-map-element', '&lt;map&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/objects.html#h-13.6.1', '&lt;map&gt;')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>{{CompatGeckoDesktop(1.0)}}<sup>[1]</sup><br />
    {{CompatGeckoDesktop(5.0)}}<sup>[2]</sup><br />
    {{CompatGeckoDesktop(17.0)}}<sup>[3]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>1.0</td>
   <td>1.0</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>1.0</td>
   <td>{{CompatGeckoMobile(1.0)}}<sup>[1]</sup><br />
    {{CompatGeckoMobile(5.0)}}<sup>[2]</sup><br />
    {{CompatGeckoMobile(17.0)}}<sup>[3]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>1.0</td>
   <td>1.0</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Starting in Gecko 5.0 {{geckoRelease("5.0")}}, empty maps are no longer skipped over in favor of non-empty ones when matching when in quirks mode. For example, consider the following HTML:</p>

<pre class="brush: html">
&lt;map&gt;&lt;/map&gt;
&lt;map&gt;
  &lt;area shape="rect" coords="25,25,75,75" href="#fail"&gt;
&lt;/map&gt;
&lt;img usemap="#a" src="image.png"&gt;
</pre>

<p>[2] Prior to Gecko 5.0, the {{HTMLElement("img")}}&nbsp;element would have matched to the second, non-empty map. Now it matches against the first one, even though it's empty.</p>

<p>[3] From Firefox 17 the default styling of the <code>&lt;map&gt;</code> HTML element is <code>display: inline;</code> and no more <code>display: block;</code>. This matches the behavior of the other browsers and was already the case in quirks mode.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{HTMLElement("a")}}</li>
 <li>{{HTMLElement("area")}}</li>
</ul>

<p>{{HTMLRef}}</p>
Revert to this revision