ACOM: Web Design Tutorial Site | ![]() |
|
Essential related topicsRelated topics |
The <AREA> tagThis tag is the real meat of image maps. It won't work without the others - the <MAP> tags have to enclose <AREA> tags or they won't work, and you then need the USEMAP attribute to point to the map. But it's through the <AREA> tag that you "draw" out the hot spots; the equivalent of making those felt-pen marks on the overhead transparency. For each hot spot you want to trace, you need an <AREA> tag. (There is no closing tag.) The first thing we need to tell the browser, then, is the SHAPE of the hot spot. SHAPE wasn't in capitals for emphasis alone, but because it's the name of the relevant attribute in this case. It can take three values, though each of the three can appear in shorthand or the full version, as given in the table below. The next thing you need to tell the browser is the co-ordinates of the shape, in other words, where it actually is on the "transparency". Have a look at the table first, and then I'll explain how the co-ordinates can be established.
Elaborating on the table above, then, the COORDS attribute takes the following values depending on the SHAPE:
To actually work out where co-ordinates lie, you will need to load the image up into a graphics editor such as Paint Shop Pro or Photoshop. These have "information windows" which, when you place the cursor over a point in the image, will give you the x and y co-ordinates of that point. It doesn't take that long to write these down and work out where your hot spot shapes are located. However, there's an even quicker way, if you have access to Dreamweaver - indeed, this is the one aspect of web design where Dreamweaver saves you a lot of bother.
Finally, you will of course need to tell the browser where the hot spot links to. Normally this is done with an HREF attribute in the <AREA> tag, in the same way as for <A> tags. If you want to use a TARGET attribute for whatever reason, stick that in there as well. By now you should know how to create the full version of the "South America" image map as was given on the introductory page of this lesson. You can return there to look at the code, but it shouldn't be all that surprising. There are some other tags which can be used on image maps. To create a hot spot that doesn't actually link anywhere, instead of the HREF attribute, put NOHREF in instead (this takes no values). ALT is also an attribute which can appear in <AREA> tags, giving different floating captions over different parts of the image. You might even try using onClick events to produce alerts or other effects. Trouble is that these are shakily supported by browsers at the present time. Using NOHREF does create a hot spot but means that the cursor will not change to a "hand" when over that hot spot. This means the spot could be easily missed. Netscape doesn't support the ALT attribute in <AREA> tags either, which means that a NOHREF hot spot in Netscape is effectively nonexistent. The map below, therefore, might look no different from a normal image to you, if viewing in Netscape. The two faces to the left, including my own mug, have been rendered as dummy links (HREF="#here", where "here" is an anchor tag lying just above the image - a dummy link of HREF="#" would return me to the top of the page each time) rather than NOHREF to give you an indication of the difference. The upshot of it all is, this map should work a lot better than it does! But at least it might serve as an indication of where things don't quite work as expected, and along the way, suggest another use of image maps on web pages beyond the actual maps I've used in the other two examples.
Remember - any image can be turned into an image map. Of course, not all do so logically, but that's not the point. It's not the image that matters, it's the "transparency" you lay over it. The best uses of image mpas are when information you want to present is directly related to different parts of an image, and this is why it is particularly appropriate for use with images such as (actual) maps, blueprints and diagrams: types of image which are already presenting graphical information. Photographs are usually more inherently illustrative, rather than informative, and it is more likely therefore that using a map on a photograph will be gratuitous or contrived. But that doesn't mean there aren't creative uses here. Just remember: always provide some alternative means of reaching the information in question for those that cannot or do not want to view images. |
Material on this site is © Drew Whitworth and ACOM, 2002. Permission will usually be given to reproduce material from this site for non-commercial purposes, if credit is given. For enquiries, e-mail Drew at drew@comp.leeds.ac.uk.