Introduction to Image Maps
An image maps is an image with clickable areas that usually act as hyperlinks.
The image is defined by the
<img> tag, and the map is defined by a
<map> tag with
<area> tags to denote each clickable area. Use the
name attributes to bind the image and the map.
To create an image map so that each of the shapes in the image below are clickable:
The code would be as follows:
You should see that the browser recognizes the areas when the cursor becomes a pointer. See a live demo on JSFiddle, or see a demonstration below:
The above parameters list is modified from the MDN docs: [`
It is feasible to create an image map's coordinates with for an image with simpler shapes (such as in the introductory example above) with an image editor that shows coordinates (such as GIMP). However, it might be easier in general to use an image map generator, such as [this one](http://imagemap-generator.dariodomi.de/).
|Below are the image map-specific attributes to use with |
<img> attributes apply.
name of the map with a hash symbol prepended to it. For example, for a map with
name="map", the image should have
|The name of the map to identify it. To be used with the image's |
|Below are |
<area>-specific attributes. When
href is specified, making the
<area> a link,
<area> also supports all of the attributes of the anchor tag (
ping. See them at the MDN docs.
|The alternate text to display if images are not supported. This is only necessary if |
href is also set on the
|The coordinates outlining the selectable area. When |
shape="polygon", this should be set to a list of "x, y" pairs separated by commas (i.e.,
shape="polygon" coords="x1, y1, x2, y2, x3, y3, ..."). When
shape="rectangle", this should be set to
left, top, right, bottom. When
shape="circle", this should be set to
centerX, centerY, radius.
|The URL of the hyperlink, if specified. If it is omitted, then the |
<area> will not represent a hyperlink.
|The shape of the |
<area>. Can be set to
default to select the entire image (no
coords attribute necessary),
circ for a circle,
rect for a rectangle, and
poly for a polygonal area specified by corner points.