| Free HTML Tutorials • CSS • Popups tutorial • Frames Tutorials • Forms Tutorials • Beginners HTML Tutorials • Advanced HTML Tutorials • JavaScripts • Free Web Page Tutorials • Free Downloads |
|
Advanced Section |
|
IMAGE MAPS |
|
|
|
|
Images Maps are useful when you have a very large graphic or want a different way to do links. We will only look at links here.
So what exactly is an image map? On the small graphic below you'll see three options ...
If you hover your mouse over each heading in turn you can read the address or URL in the task bar. If you click each section of the image you will go to the named part of this tutorial. All the links are on this one graphic or image which is why it is called an IMAGE MAP.
One advantage of using an image map is that you use ONE image instead of several for, say, a navigation bar.
To start with you will need to create a suitable image. A simple bar like this takes a couple of minutes with your favourite graphics programme. Or find one floating around that seems the right shape. For now stick to rectangular shapes as they are easier to define.
Add the image to your page with same image tag as usual, but with a new attribute, USEMAP. You will notice the USEMAP is named, but we'll look at that a bit further down.
DEFINING MAP CO-ORDINATES First we need to tell the browser that we are using a map with this image, so we add the USEMAP="#navbar" command to the end of the image tag. It is essential to define the WIDTH and HEIGHT of the image as we will be using these to create the co-ordinates to define the map. You can put the co-ordinates any where on the page, but for convenience it is probably best to put it right after the IMG tag. These are the co-ordinates for our little navigation bar:
We have given our map the name "#navbar" which is located after the tag USEMAP.
Taking the first line, we now define the shape of our map:
It's probably a good idea to work out the whole map on paper first. Just draw a simple rectangle and work out the measurements and co-ordinates for each part of the image map, like that shown below:
The image size in this example is 300 x 30. In effect we are going to define the three small rectangles contained within the image. Each will be approximately 100 X 30.
We need a closing tag to end this:
I will now try to make life easy for all of us. If you want to use a very complex map for navigation or some other purpose, don't use HTML, use a map creation programme. There are some inexpensive (or free) shareware image map creation programmes available. Also most of the better web creation programmes will do it all for you. Check out the references in TIPS for software sites or try your favourite search engine.
Help
|