Take the FXDepot Quiz! Creating Image Maps With HTML: Tutorial 1 | FXDepot Productions

Our Pages

Friday, April 15, 2011

Creating Image Maps With HTML: Tutorial 1

Posted on 12:49 AM by Ram Sidh

Since, during the three-part series of "What is HTML?", I never really explained what the exact syntaxes were for each tag, or how to exactly structure the page, you can download my free e-book: HTML: A Basics Guide. It will give you a completely new understanding of HTML and will allow you to understand it better. It will explain the syntaxes much more deeply and how to use them in several situations. 

If you wish to download the Free e-book now, click here.



In one of my last articles, actually part of the "What is HTML?" series, I began discussing about creating image maps, independent clickable areas on an image, that can serve as links to specific sites that are defined in HTML code. I explained how it was written, the "title" attributes, the "href" attribute and the "shape" attribute. But I intentionally left out the "coords" attribute, because it was a little more advanced so to say, in respect to the article I had written. 

So, I've come back and written out this article, which thoroughly explains image mapping, its potential applications and how to create them using the HTML code. The "coords" attribute, is short for "coordinates" and implies that itself. In order to define a specific area on any image, or plane surface, we need a system by which the browser can recognize it. So, in this case, we're going to be using the basic Cartesian system of coordinates to define the area on the image. 

As I stated in the previous article: the "shape" attribute comes in 3 types in HTML. a) rectangle b) circle c) polygon. The most favorable shape that is used to define areas on a surface, is the rectangle. Circles can also be used, when we deal with buttons that around round. Polygons have much more wider applications because a much more specific form of the area can be obtained by using this shape. But, for some unknown reason, the "rectangle" is usually preferred over the others.

So, what we do is, we first decide which shape we need to use to define our image maps. After that, we have to decide the appropriate coordinates we will enter as the value to the "coords" attribute. Now, I know it is impossible to actually manually find out what coordinates the area belongs to relative to the image itself, but there is a great website, where you can actually upload your image, map it after choosing your shape, and then get the respective coordinates.

If you want to visit it, please click here.

Once you've got the coordinates for your shape, then you can create the "href" attribute, which will create the link that clicking on that area will take you to. 

So, for instance, if I have a picture of myself, and a great big RV next to me, and I especially love my RV. I want to advertise the shop that got me this wonderful RV, and I want to also share my Facebook profile page to all of my friends.

So, I have a crazy idea! I want to take that same picture, and change it somehow, so that whenever somebody clicks on the part of the image that contains me, it will directly take them to my Facebook profile page, whereas, if anyone clicks on the part of the image that contains just the RV, it will take them to the RV's seller's online website. 

So here, the use of image maps comes into play. So first, we'll insert he image using the <img> tag and the "src" attribute. Then, we'll create a title for it using the "title" attribute. Maybe we'll name it something like: Me & My RV! After that, we'll create a "usemap" attribute, and type in the image's identity. Then we'll open the <map> tag, and in the "name" attribute, we'll write in the identity we gave the image in the "usemap" attribute. Once we've don that, we'll open the <area> tag, and respectively fill out the details of each of these attributes for both the image maps: "shape", "coords", "href" and "title".

So here is how the code will look like:

<html>
<body>
<img src="meandmyrv.jpg" title="Me & My RV!" usemap="#meandmyrv">
<map name="meandmyrv">
<area shape="rect" coords="31,564,73,231" href="http://www.facebook.com/" title="My Facebook Profile Page!">
<area shape="rect" coords="45,587,21,134" href="http://www.bigcowvehicles.com/" title="Big Cow Vehicles Ltd.">
</map>
</body>
</html>

As you can see, this is how it is done. The coordinates I've entered here are just bogus, and are dummy coordinates. The image I've tried to insert is from my own PC, and if you want to insert one from the Internet itself, you can copy paste its URL instead. 

Give us some more feedback by replying to this article using the Comment boxes. Also, participate in our monthly polls, and please vote for any of them! Thank you!

2 Response to "Creating Image Maps With HTML: Tutorial 1"

.
gravatar
Ram Sidh Says....

Please post some more feedback and encourage the sharing of ideas between the techie community!
Somnium

.
gravatar
Eden Gold Says....

Really amazed! It is all totally extremely, specific, open up can be a description in the problem. It includes the info.

Runescape Gold
Sell Runescape Gold

Leave A Reply