build-website-header
spacer-image
 

Image Maps

Any Image can be turned into a clickable link by surrounding it with HTML anchor tags. An Image map however contains multiple links within the same image.

Creating an Image Map

There are two types of image maps:

  • Server side- Rely on cgi scripts on the server and are more difficult to set up, and are not really used anymore.
  • Client side- These are interpreted by the users browser and are relatively easy to set up and run faster than server side maps. These are the only ones we will consider.

An image map consists of two components:

  • The Image- This can be any GIF image.
  • The HTML for the links and image sections.- This is usually created by a graphic program but can be done manually with a little trial and error.
Most graphic programs will create image maps the one I will be using is Serif Photoplus 6.0 which is available as a free download.

For this example the starting image is a simple menu image with text for the home page and the contact page. We are going to turn the text on the image into links.

It should be noted that the image isn't changed by the process. Meaning that any existing image can be used to create an image map. The image map process just uses the image to calculate the co-ordinates of the image hotspots. Here is the Image:

create image map 1

The image map toolbar is on the bottom of the left toolbar and has an arrow pointing to the  left and and drop down selection arrow:

create image map 2

Click the toolbar and select the image  map shape (I used a square) Then use it to outline the part of the image that will act as the link (here the text-home)

create image map 3

Then click the image toolbar icon again. This will confirm the selection.

create image map toolbar 2

Now click inside the selected area it should have a border around it (see below) then right click and select properties.

create image map properties

A image map text box appears. Enter the text that will be displayed when the visitor hovers over the link and the URL of the link. I have used a relative link in the example below.

If you use the full url with the http:// .. then you may find that it doesn't all fit in the text box. If that happens enter as much as possible and remember to edit the generated html code manually.

create image map link

 

Repeat the above process for the contact link.

Click ok and its done. Now Click export the Create html checkbox should be automatically ticked and then give it a name (here menu) and click save.

create image map generate code

Two files are created an .gif file ( the image)  and an HTML file ( the image map).

 

Image Map HTML

Here is the HTML generated.

<IMG BORDER="0" SRC="menu.gif" ALT="Exported picture" USEMAP="#PreviewImageMap" ISMAP="ISMAP">

<MAP NAME="PreviewImageMap">
<AREA SHAPE=RECT HREF="http://www.build-your-website.co.uk/conta" ALT="contact" COORDS="12,51,97,73">
<AREA SHAPE=RECT HREF="index.htm" ALT="Home" COORDS="13,18,94,45">
</MAP>

I've highlighted the contact link in yellow to show that it isn't complete. You need to manually edit this to correct it. The Home page link is shown in green, and is ok.

It is the COORDS attribute which picks out the image hotspot, the ones for the contact I've highlighted in purple.

The 12,51 is 12 pixels horizontal (x) and 51 pixels vertically measure from the top left corner of the image and 97,73 is 97 pixels horizontal (x) and 73 pixels vertically measure from the top left corner of the image marking the upper left and lower right corners of the rectangle.

Here is the result (opens in another window). If you place the mouse over the text you will see that they are in fact links:

 

Google
Web www.build-your-website.co.uk

Related Articles and Resources:

 

 

Image Maps

spacer2-image