You've learned how to use an image to link to another page, but did you know that you can subdivide a single image and link each part of that image to another page? This type of subdivided image is called an image map. Image Map
You've probably seen image maps on the Web, even if you didn't know what they were. Rather than creating a different image for each button in the navigation bar, many Web designers create a single image that contains all the buttons and then use image maps to link each button to the appropriate page. Figure 9.1 shows one example of such a navigation bar. Look at the following additional examples:
Figure 9.1. This image has been subdivided into four parts (one for each button on my navigation bar). Notice that some pieces of the image will not be linked to anything. Do not draw the boxes on your own image; I included them for demonstration purposes.Finding the CoordinatesLike any other map, image maps have coordinates. In an image map, the coordinates, which are written as pixels, mark the corners of the piece of the image that will be linked to a specific URL. Before you can create any image map, you have to know the coordinates for your image. Many image editors are available that can help you determine these coordinates and give them to you in a file so that you can cut and paste them into your HTML document. However, it's a lot easier to let your image editor do the work for you. Just type "create image map" into your favorite Web search engine to find several applications. Tip
If you want to create your own image map, use the image editor to find the coordinates, write them down, and add those coordinates to your HTML file. Figure 9.2 shows you how Paint Shop Pro displays the coordinates for an image. I highlighted the portion of my navigation bar that I wanted to map to my home page and Paint Shop Pro told me which coordinates to use. As the figure shows, the highlighted section is a rectangle with corners at 1, 107 and 189, 167. Figure 9.2. Paint Shop Pro displays the coordinates of a selected region of the image in the lower-left corner.Tip
Caution
Client Side Versus Server SideWith HTML, you can create image maps that work on the client side and the server side. The following list indicates the differences:
So how do you know which one to use? Most Web page authors only use client-side image maps because they are faster and anyone with a version 3.0 browser or higher can view them. You can always provide text links for older browsers that don't recognize the client-side image maps. Because client-side image mapping is the type of image map used most often, it is the one you'll learn about in the following section. Tip
|