
To create a client side image map requires the introduction of two new tags:the map tag and the area tag. The map tag defines the map's name and other attributes and contains the area tags. Each area tag defines the shape of the hot spot and the URL associated with it. The three button example involved three areas tags each with a rectangular shape the size of each button.
Note the image has its upper left point (x,y) = (0,0) and its lower right coordinate at (N-1, M-1) where the image width= N pixels and its HEIGHT= M pixels. In the three button example it is easy to determine the coordinates that are associated with each hot spot once we know the image's size. To specify a rectangular hot spot we define its shape =rect and give the rectangle's upper left and lower right coordinates. In the example the source image is 300x50 pixels.
Before going further, let us look at the code for the above simple example.
<PRE>
<P><!-- the Map is named menu and contains three rectangular hot spots -->
<MAP NAME="menu">
<!-- The area tag has two attributes Shape, in this example set to "RECT", and COORDS = (X-upper_left),(Y-upper_left),(X-Lower_right),(Y-lower_right) where the COORDS is a list of integers seperated by commas set off in quotes. Since the source gif (menu.gif) is 300 x 50, the left button (1) is one third the length. Hence, upper left is (0,0) and lower right is (100 -1, 50-1)= (99,49). HREF="left.html" tells that the click will link us to left.html located in this directory. -->
<AREA SHAPE="RECT" COORDS="0,0,99,49" HREF="left.html">
<AREA SHAPE="RECT" COORDS="100,0,200,49" HREF="middle.html">
<AREA SHAPE="RECT" COORDS="200,0,299,49" HREF="right.html">
</MAP>
<!-- Next we create an in-line image with source menu.gif and a USEMAP attribute = "#menu". The attribute USEMAP tells the browser to look for a client side map named menu. The # sign is necessary. -->
<IMG USEMAP="#menu" SRC="menu.gif" HEIGHT=50 WIDTH=300><BR>
</P>
</PRE>