Original slides by TA Tanner Means
Image Mapping allows you to define clickable areas in an image.
Image credit: Webaid, NC state gov
<img>
and <map>
Add the usemap
attribute to the <img>
you want to map.
usemap
's value should be:
"#" + the map's name
attribute
attribute of the <map>
element.
<img src="URL" id="id" usemap="#MapName" alt="text">
The <map>
tag only has the name
attribute.
<map name="MapName"> area tags (next slide) </map>
<area>
Every area tag corresponds to a clickable area in the image
<area shape="rect" coords="0,0,82,126" href="http://www.wikipedia.org" alt="Wiki" />
Attribute | Value | Description |
---|---|---|
shape |
default rect circle poly |
Specifies the shape of an area |
coords | coordinates | Specifies the coordinates of an area |
href | URL | Specifies the hyperlink target for the area |
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap" /> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun" /> <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury" /> <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus" /> </map>
Values for the shape
and coords
attribute:
Value | Description | Coordinate attribute value |
---|---|---|
default | Specifies the entire region | "" |
rect | Defines a rectangular region | "x1,y1,x2,y2" |
circle | Defines a circular region | "x,y,radius" |
poly | Defines a polygonal region | "x1,y1,x2,y2,..,xn,yn" |
Let's map Obama's facial features to pertinent websites
So what could we do with this?
Here's what Tanner thought of