Rectangle Circle Polygon Default || Rollover 1 Rollover 2 Dynamic Hotspots 1 Dynamic Hotspots 2 Dynamic Hotspots 3
Normally you use one image with one link, with an imagemap you can have multiple links within any image of your choice. Areas within the image are designated as Hotspots which then act as a hyperlink.
Knowing the height and width of the image that you are going to use is important when deciding the size and shape of the hotspot(s)
Siting the hotspots will depend on the contents of the image and will be the main infuence with this decision, a square object, circular object, or a multi-sided object.
To find the co-ordinates where the shape will be, load the image as normal using the IMG tag and add the attribute isMap to the image tag.
IsMap shows the co-ordinates of the cursor within the image in the status bar. The image tag at this stage also has to be enclosed within <A> tags, which are deleted along with isMap once you have your co-ordinates.
<a href="#null">
<img src="image.jpg" border=0 width="200" height="200" isMap>
</a>
Move your cursor over the image below and look in the status bar, this is a quick and simple way of getting your co-ordinates.
Or you can load the image into an image editor with its cursor position function and write down the co-ordinates.
To use an image as an image map you include the attribute usemap and assign it a name usemap="#mapname".
<img src="your image.jpg" border="0" width="200" height="200" usemap="#mapname">
Enter the opening MAP tag and name it the map name that you gave usemap in the img tag.
Enter your AREA tag(s), and finally the closing MAP tag.
<map name="mapname">
<AREA SHAPE="RECT" coords="x1,y1,x2,y2" href="your page.htm" alt="your message here">
</map>
Within the AREA tag is where you state the SHAPE and the CO-ORDINATES of the hotspot you want to create.
You also include your link information, your ALT message, and any onmouse events.
For each shape or hotspot you must have a separate AREA tag, this allows you to have a mixture of different shapes.
To create a rectangular or square Hotspot the co-ordinates are stated as follows:
shape="rect" coords="x1,y1,x2,y2"
This is:
The image below has four hotspots, for the examples on this page I have outlined the hotspots with a red dotted line.
Click the hotspots in the image or hold your mouse there for a moment to see the ALT message.
<img src="yourimage.jpg" usemap="#mapone" border=0 width=250 height=200>
<map name="mapone">
<area shape="rect" coords="10,10,80,80" href="#null" alt="Hotspot 1" onclick="alert('Hotspot 1')">
<area shape="rect" coords="170,10,240,80" href="#null" alt="Hotspot 2" onclick="alert('Hotspot 2')">
<area shape="rect" coords="10,120,80,190" href="#null" alt="Hotspot 3" onclick="alert('Hotspot 3')">
<area shape="rect" coords="170,120,240,190" href="#null" alt="Hotspot 4" onclick="alert('Hotspot 4')">
</map>
Requires the center point and radius (x,y radius).
x,y is the position of the center of the radius
![]() |
|
<img src="alien.jpg" usemap="#maptwo" border=0 width=288 height=220>
<map name="maptwo">
<area shape="circle" coords="76,53 45" href=" ">
<area shape="circle" coords="222,53 45" href=" ">
<area shape="circle" coords="76,167 45" href=" ">
<area shape="circle" coords="222,167 45" href=" ">
</map>
Requires the coordinate of each vertex (point (x1,y1)) of the area you want to define.
You can define up to 100 points: POLY (x1,y1,x2,y2, etc,etc).
The polygon allows you to trace round objects within your images.
In the image below I have made the head of the alien one hotspot and the alien body a second hotspot.
<img src="alien.jpg" usemap="#mapthree" border=0 width=250 height=200>
<map name="mapthree">
<area shape="poly" coords="110,6,120,10,122,18,122,28,116,44,110,48,102,44,96,28,96,18,100,10,110,6" href="#null" alt="I am the HEAD" onclick="alert('The HEAD says Hi')">
<area shape="poly" coords="126,54,130,60,130,78,130,98,126,110,127,158,120,162,119,168,110,163,104,168,100,164,89,158,92,102,88,60,102,44,110,48,126,54" href="#null" alt="I am the BODY" onclick="alert('The BODY says Hi')">
</map>
DEFAULT(x1,y1,x2,y2)
Specifies the pixel locations for the entire image
As well as having hot spots in the image the rest of the image can be also be used as a link.
The default area tag must be entered last in the map tags otherwise it will override any other hotspots.
<img src="alien.jpg" usemap="#mapfive" border=0 width=288 height=220>
<map name="mapfive">
<area shape="rect" coords="10,10,70,70" href="#null">
<area shape="circle" coords="210,40 30" href="#null">
<area shape="poly" coords="110,6,120,10,122,18,122,28,116,44,126,54,130,60,130,78,130,98,126,110,127,158, 120,162,119,168,110,162,104,168,100,164,89,158,92,102,88,60,102,44,96,28,96,18,100,10,110,6" href="#null">
<area shape="default" coords="0,0,250,200" href="#null">
</map>