Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
Client-Side Imagemaps
Once you have the coordinates written down, you're ready to create an HTML imagemap. Type the following just after the <body> tag in your Web page:
<map name="brainmap">
(You can use whatever name you want if brainmap doesn't describe the image you're using very well.)
Now you need to type an <area /> tag for each region of the image. Figure 14.6 shows how you would define the eight regions of the brain image.
Figure 14.6 The <map> and <area /> tags define the regions of an imagemap.
Each <area /> tag in Figure 14.3 has three attributes:
- shape indicates whether the region is a rectangle (shape="rect"), a circle (shape="circle"), or an irregular polygon (shape="poly").
- coords gives the exact pixel coordinates for the region. For rectangles, give the x,y coordinates of the top-left corner followed by the x,y coordinates of the bottom-right corner. For circles, give the x,y center point followed by the radius in pixels. For polygons, list the x,y coordinates of all the corners, in connect-the-dots order.
- href specifies the page to which the region links. You can use any address or file name that you would use in an ordinary <a href> link tag.
After the <area /> tags, you are done defining the imagemap; insert a closing </map> tag.
To place the actual imagemap on the page, you use an ordinary <img /> tag and add a usemap attribute:
<img src="brain.gif" usemap="#brainmap">
Use the name you put in the <map> tag (and don't forget the # symbol). It is best to include width and height attributes for any image on a Web page.
Figure 14.7 shows the imagemap in action. Notice that Microsoft Internet Explorer displays the link address for whatever region the mouse is moving over at the bottom of the window, just as it does for "normal" links. If someone clicked where the mouse cursor (the little hand) is shown in Figure 14.7, the page named fantasy.htm would come up.
Figure 14.7 The imagemap defined in Figure 14.6 appears like this on the Web page.
Server-Side Imagemaps | Next Section

Account Sign In
View your cart