Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Html Image Links

Hello every one! welcome to this section of my Html tutorial. In this tutorial i wanna be talking about HTML image links. You all know that in my last tutorial i treated HTML text links and how to use these links to connect various webpages to form a complete website and also how to link various sections of a particular webpage.
So quickly lets looks at HTML image links, lets consider the example below.

Example
it's simple to use an image as hyperlink. All you need do is to use the image inside the hyperlink at the piece of text as shown below;




Image Hyperlink Example


Click the following link



    



The above example will produce a result where you can click on the image that will take you directly to web design tutorialz home page. You can try that out your self and take note that it is adviceable to store all the images which you will need for your web design project in one folder.

Mouse-Sensitive Images
The HTML and XHTML standards provides a feature that lets you embed many different links inside a single image. What i mean by that is that you create various links on a single image based on different coordinates available on the image. Once different links are attached to different coordinates, we can then click various parts of the image to open target documents. Such mouse-sensitive images are known as image maps.
   There are two ways in which we can create image maps;

Server-side image maps - This is enabled by the ismap attribute of the tag and requires access to a server and related image-map processing applications.

Client-side image maps - This is created with the usemap attribute of the tag, along with the corresponding and tag.

Server-Side Image Maps
Here you simply put your image inside a hyper link and use ismap attribute which makes it special image and when the user clicks some place within the image, the browser passes the coordinates of the mouse pointer along with the URL specified in the tag to the web server. The server uses the mouse-pointer coordinates to determine which document to deliver back to the browser.

when ismap is used, the href attribute of the containing
tag must contain the URL of a server application like a cgi or PHP script etc, to process the incoming request based on the passed coordinates.
  The coordinates of the mouse position are screen pixels counted from the upper-left corner of the image, beginning with (0,0). The coordinates, preceded by a question mark, are added to the end of the of the URL.
For example, if a user clicks 20 pixels over and 30 pixels down from the upper-left corner of the following image;

Which has been generated by the following code snippet:




ISMAP Hyperlink Example


Click the following link



    




Then the browser sends the following search parameters to the web server which can be processed by ismap.cgi script or map file and you can link whatever documents you like to these coordinates;

/cgi-bin/ismap.cgi?20, 30

This way you can assign different links to different coordinates of the image and when those coordinates are clicked, you can open corresponding linked document
Note:Cgi programming is not part of our tutorial courses, at least not yet so you will learn cgi programming when you study Perl programming and there are varieties of sites that treat those courrses. You can write script to process these passed coordinates using PHP or any other script as well. For now lets concentrate on html.

Client-Side Image Maps
 Client side image maps are enabled by the usemap attribute of the tag and is defined by special and extension tag.
The image that is going to form the map is inserted into the page using the tag as a normal image, except it carries an extra attribute called usemap. The value of the usemap attribute is the value which will be used in a tag to link map and image tags. The along with tags defines all the image coordinates and corresponding links.
The  tag inside the map tag, specifies the shapes and the coordinates to define the boundaries of each clickable hotspot available on the image. Below is an example of the image map:




USEMAP Hyperlink Example


Search and click the hotspot


    


 coords="80,80,20"  href="/html/index.html"  alt="HTML Link"  target="_blank" />
coords="4,6,60,60"  alt="CSS Link" href="/CSS/index.html"  target="_blank" />




Coordinate System 
The actual value of the coords is totally dependent on the shape in question. Here is a summary to be followed by detailed examples:
rect=X1, Y1, X2, Y2
x1 and y1 are the coordinates of the upper left corner of the rectangle; x2 and y2 are the coordintates of the lower right corner.
Circle=Xc, Yc, radius
 xc and yc are the coordinates of the center of the circle, and radius is the circle's radius. A circle centered at 200,50 with a radius of 25 would have the attribute coords="200,50,25"
Poly = X1, Y1, X2, Y2, X3, Y3, ------Xn, Yn
The various x-y pairs define vertices (points) of the polygon, with a "line" being drawn from one point to the next point. A diamond-shaped polygon with its top point at 20,20 and 40 pixels across at its widest points woild have the attribute coords="20,20,40,40,20,60,0,40".

All coordinates are related to the upper-left corner of the image (0,0). Each shape has a related URL. You can use any image software to know the coordinates of different positions.

HTML Email Tag
HTML
tag provides you option to specify an email address to send an email. While using tag as an email tag, you will use mailto; email address along with href attribute. Following is the syntax of using mailto instead of using http.

Send Email
   This code will generate the following link whicvh you can use to send email.

Send Email

Now, if a user clicks this link, it launches one Email client (like Lotus Notes, Qutlook Express etc. ) installed on your user's computer. There is another risk to use this option to send email because if user don not have email client installed on thier computer then it would not be possible to send emaols.

Default settings 
You can specify a default email subject and email body along with your email address. Folloowing is the example to use default subject and body.

Seend Feedback


well thats it for this tutorial, see you in my next tutorial, bye for now.

 Links to previous tutorials on HTML : Html Introduction,  Html Tags,  Html Document Structure,  The Doctype Declaration, Html Basic Tags, Html Basic Tags2 , Html Elements ,
Html Attributes , Html Attribute 2, Html Formating,Html Formatting[CONTINUATION],Grouping Content, HTML-Phrase Tags,  Html-Phrase Tags[CONCLUSION] , Html-Meta Tags , Html-Comments, Html Images , Html Tables , Html Tables(Conclusion) , Html List , Html Text Links
 ,


This post first appeared on Web Design Tutorialz, please read the originial post: here

Share the post

Html Image Links

×

Subscribe to Web Design Tutorialz

Get updates delivered right to your inbox!

Thank you for your subscription

×