HTML Image Map has been around all this while, and yet not many web pages are using it when it comes to single image with multiple links. It’s really handy and fast for web designers or developers to create multiple “Hot Spots” linking within a single image, without slicing any image for linking.
For instance, your client has given you a list of sponsors and he wants each of the logo to be linked to the sponsor’s web page on his website. You may want to try out Image Map, it will make your job much easier.
What Is Image Map?
Basically, Image Map is a way that allow you to define certain area to be linked within a single image on a web page. This means that, rather than having to link the whole image as one link, you can have lots of different links within that one image.
Still not sure what is Image Map? Check out the demo.
Before we start here are the general attributes for the
<br /><map name="map-name"> <area title="area title" alt="alternate text" coords="area coordinates" shape="area shape" href="area hyperlink" target="hyperlink target" nohref="nohref" /> </map> <br />
Most of the attributes are used quite often, let’s talk about the
shape and the coords attributes. For
shape attribute it have
rect | circle | poly | default.
coords attribute, below is a simple overview diagram for the coordinates.
In this tutorial, you will see how you can link several logos to their web pages within a single image. First is to have your image ready, here I mashed up some of the popular web logos into one image.
First create your normal image HTML markup, notice
usemap="#logos" attribute, this is to associate the image map with the image.
<br /> <img alt="Web Logos" src="images/weblogo.jpg" usemap="#logos" /><br /><br />
Next you will need to find out the coordinates for each of the logo using Photoshop. Let start with a circular logo, first load the image into Photoshop, press F8 for the Info Panel to appear, move your cursor to centre of the circular logo and note down the coordinates.
We will also need to find the radius of the circle. By finding out the difference between the edge of the circle’s coordinates and centre coordinates of the circle, or by using the rule tools in Photoshop. Either way will help you find out the radius of the circle.
Now let’s find the coordinates for a rectangular logo. You just have to find out the top left and bottom rightcoordinates of the rectangular logo. Using the same method above you will be able to find the coordinates easily.
Once you have find out all the coordinates for each logo, now everything is easy. Just follow the attributes for theMap Tag listed above and enter all the coordinates for each of the shapes you have found.
<br /><map name="logos"> <area title="StumbleUpon" alt="StumbleUpon" coords="68,56,33" shape="circle" href="http://www.stumbleupon.com/" /> <area title="Youtube" alt="Youtube" coords="220,19,306,54" shape="rect" href="http://www.youtube.com/" /> <area title="Google" alt="Google" coords="367,32,516,84" shape="rect" href="http://www.google.com/" /> <area title="Wikipedia" alt="Wikipedia" coords="556,12,639,115" shape="rect" href="http://www.wikipedia.com/" /> <area title="Skype" alt="Skype" coords="128,62,244,114" shape="rect" href="http://www.skype.com/" /> <area title="Yahoo" alt="Yahoo" coords="301,103,444,136" shape="rect" href="http://www.yahoo.com/" /> <area title="eBay" alt="eBay" coords="25,158,135,207" shape="rect" href="http://www.ebay.com/" /> <area title="Flickr" alt="Flickr" coords="180,147,271,175" shape="rect" href="http://www.flickr.com/" /> <area title="Digg" alt="Digg" coords="299,166,379,208" shape="rect" href="http://www.digg.com/" /> <area title="Wordpress.org" alt="Wordpress.org" coords="500,184,32" shape="circle" href="http://wordpress.org/" /> <area title="Blogger" alt="Blogger" coords="599,142,667,209" shape="rect" href="http://www.blogger.com/" /> <area title="Default" alt="Default" shape="default" nohref="nohref" /> </map> <br />
For custom shape link, you can try
poly shape attribute. Just defining those important coordinates and it will form up a more precise Hot Spot area for the link.
Special thanks to Terrance.