![]() |
![]() |
Image maps are dynamic or active images embedded in html documents. By clicking on different regions of an image map the user links to different documents or URLs. Image maps can be great space savers, allowing designers to place several links into a small area. They are an alternative to text-based navigation elements.
An imagemap allows you to define specific regions of an image that you have created or scanned and uploaded to your www directory. These sections or hot spots are defined by the web page designer using standard HTML markup tags. This markup may be either in a separate file or in the same web page as the image.
You can construct image maps in one of two ways. One way is called theclient-side image map. Client-side maps depend upon the browser to read the map coordinates that define the hot spots and call up the appropriate document.
The second way, called the server-side image map, sends the chosen coordinates defining the boundaries of the hot spots to a script located on the server which then returns the document to the user.
Client-side image maps can be read by most of the popular browsers including Netscape Navigator 2.x (and higher), Microsoft's Internet Explorer and AOL's browser. However, they cannot be read by screen reader software or text-based browsers, so it is still important to provide alternative methods of access to your links.
| This image is a client-side image map. Every region in the image has been defined and associated with a specific URL. Counting the white space, the image has been divided into three distinct regions, a rectangle, a circle, and a polygon and a region made up of "what's left" (the white space). There are URLs that are associated with each region leading to four different documents.
If you click on any of the three elements, you will be sent to a different document. If you click anywhere in the white space, you will be sent to a default document. On this page, you'll see the actual markup for this map, called IUimage.gif. This link opens a new browser window, so you should close it when you are ready to return here. On this page, it is embedded at the bottom of the page markup. The individual lines of HTML code that make up this image map are described below. |
Client-side image maps consist of three elements:
1: Create the image file
2: Define the hot spots in the image file
You can use three shapes:
The easiest way to determine the coordinates of these shapes is to use an imagemapping program like MapEdit or WebMap. In addition, most graphics programs will show you the coordinates, generally at the bottom of the screen in the message bar or in a separate window (as in the case of Photoshop).
You can then write these coordinates down and insert them into the HTML code, as will be described below.

| Upper left x=10, y=8
Lower right x=260,y=58 | ![]() |
Then, subtract the larger from the smaller number. This gives you the radius of the circle.
For the circle in the image above, the coordinates you need to get the ones used in the map file are:
| Center of the circle x=70, y=149
Point on the circumference of the circle x=70, y=204 This makes the radius r=55 |
![]() |
So, for the circle in the image above, the coordinates are:
x=70, y=149, r=55
| Angle 1 x=162, y=81 Angle 2 x=185, y=68 Angle 3 x=245, y=67 Angle 4 x=252, y=195 Angle 5 x=211, y=235 Angle 6 x=188, y=237 Angle 7 x=166, y=241 Angle 8 x=134, y=235 Angle 9 x=158, y=190 Angle 10 x=162, y=80 |
![]() |
| Upper left x=0, y=0
Lower right x=268, y=249 |
|
3: Create the map file
Now we're getting to the fun part!
The chunk of html code generally referred to as the map file does not have to be a separate file. But it does have to contain the following information:
The alt="text" attribute is also used with the area attribute and provides a text alternative to the image.
<area shape="rect" coords="x1,y1,x2,y2" />
<area shape="circle" coords="x1,y1,r1" />
<area shape="poly" coords="x1,y1,x2,y2,x3,y3...xn,yn" />
<area shape="rect" coords="x1,y1,x2,y2" href="url.html" />
If you want nothing to happen when a user clicks on a region of the image, you can use the nohref attribute as follows:
<area shape="rect" coords="x1,y1,x2,y2" nohref />
4: Place the image map into the html document
So, when the image mapis created, where does it go in the document? And where does the map file go?
<img src="IUimage.gif" usemap="#image" alt="IU Icon ImageMap - Client-Side" border="2" height=250 width=269 align="left" />
In this example, the markup should look familiar, with the exception of one element:
usemap="#image"
This is an attribute that acts as a target identifying the image as an image map for the browser. The target # tells the browser where to locate the map file. usemap= directs the browser to the map file elsewhere in the document, which contains the anchor:
<map name="image">
It is also possible to place the map file in a different document, in which case the <usemap> element acting as the target must contain the URL of the document. In generic form, the following markup would work:
<img src=/directory_name/image.gif" usemap="/directory/filename#name_of_map_file" />
5: Click away!
Now that wasn't so bad, was it? Oh...one more thing.
| circle.html | rect.html | polygon.html | other.html |
|---|
Once you master image maps a whole new world of web page design is open to you. You don't have to link to static pages, you can click on an image and send a query to a database, launch a java applet, or a start a QuickTime movie. See, I told you it was easy.
Here's another example of a client-side image map that you can use.
Server-side image maps have four elements:
There are three steps involved in creating a server-side image map.
1: Create the image file
2: Place the image map in the html Document
So, the generic markup for the image that will be the image map would look like this:
<img src="/user/image.gif" ismap>
<a href="/cgi-bin/imagemap/user/image.map"> <img src="/user/image.gif" ismap></a>
This address is actually two addresses joined together. The first part, /cgi-bin/imagemap is the address of the imagemapping program which (hopefully) will already be installed on your server. The second part of the address, /user/image.map, is where the .map file can be found.
For servers that do not need to call the imagemapping program link directly to the map file:
><a href="/user/image.map"> <img src="/user/image.gif" ismap></a>
3: Create the map file and place in directory
The server-side map file for the IU Icons Image is:
rect rect.html 10,8,260,58
poly polygon.html 62,81,185,68,245,67, 252,195,211,235,188,237,166,241,134,235,158,190,162,80
circle circle.html 70,149,55,202
default other.html
This file would be called something.map and could be placed in the same directory as the image file.
To find the coordinates for the areas you can use the same methods as described above (a graphics program or imagemap program).
4: Start clicking!
Not too shabby. Now let's try tables!
| Demo Page Navigation: |
DemoPage contents | About HTML | UNIX help | HTML tags | Lists | Links | Images |
| Imagemapping | Tables | Forms | Frames | Javascript | CSS (style sheets) | XML |
|---|
| Page by Howard Rosenbaum | |
| Find me at hrosenba@indiana.edu | http://www.slis.indiana.edu/hrosenba/www/Demo/Demo12.html |