HTML Image Maps

Image maps provide a mechanism for providing clickable areas in an image. There are in fact two types of image maps - the, older, server-side map specification is best avoided since it creates additional server traffic. We only discuss client-side image maps.

Within a map we define clickable areas - the so called hot spots. Clicking on a hot spot invokes an action - such as loading another HTML page, calling a JavaScript function etc. In our example we have chosen to merely show a JavaScript alert since we did not want to have another page displayed while discussing image maps. There are three steps to using image maps

The code used to create the image map on this page is shown below.

<html>
   <head>
   </head>
   <body>
      <map name="shapes">
         <area shape="rect"  href="javascript:alert('I am a rectangle')" coords="11,20 107,78">
         <area shape="circle"  href="javascript:alert('I am a circle')" coords="162,116 41">
         <area shape="poly"  href="javascript:alert('I am a polygon')" coords="204,30 251,22 274,43 258,78 221,85">
      </map>
      <img usemap="#shapes" src="/images/immap.png" border="0">      
   </body>
<html>

There are several additional points worthy of note

Jump To...

Colophon