Now that we have seen the various way to create text links and that we also learned the way to display images in our webpages. Now, we'll find out how to use make image links.
It's simple to use a picture as a hyperlink. We just got to use a picture inside hyperlink at the place of text, as shown below :
<!DOCTYPE html> <html> <head> <title>Image Hyperlink Example</title> </head> <body> <p>Click following link</p> <a href = "https://siigo.com" target = "_self"> <img src = "/images/logo.png" alt = "Siitgo" border = "0"/> </a> </body> </html>
This will produce a result, where you'll click on the pictures to succeed on the house page of Siitgo.
This was the only way of making hyperlinks using images. Next, we'll see how we will create Mouse-Sensitive Image Links.
The HTML and XHTML standards provide a feature that allows you to embed many various links inside one image. you'll create different links on the only image supported different coordinates available on the image. Once different links are attached to different coordinates, we will click different parts of the image to open target documents. Such mouse-sensitive images are referred to as image maps.
There are two ways to make image maps:
1. Server-side image maps: This is often started by the ismap HTML attribute of the <img> tag and it often needs access to a server and similar image-map processing application.
2. Client-side image maps: This is generates with the usemap HTML attribute of the <img> tag, including the follow up <map> and <area> HTML tags.
The server uses the mouse-pointer coordinates to work out which document to deliver back to the browser.
When ismap is employed, the href attribute of the containing <a> tag must contain the URL of a server application sort of a cgi or PHP script, etc. to process the incoming request supported the passed coordinates.
The coordinates, preceded by an issue mark, are added to the top of the URL.
For instance, if a certain user clicks 20 pixels over and 30 pixels down right from the upper-left corner of the subsequent image that has been generated by the subsequent code snippet:
<!DOCTYPE html> <html> <head> <title>ISMAP Hyperlink Example</title> </head> <body> <p>Click following link</p> <a href = "/cgi-bin/ismap.cgi" target = "_self"> <img ismap src = "/images/logo.png" alt = "SIITGO" border = "0"/> </a> </body> </html>
Then the browser sends the subsequent search parameters to the web server which may be processed by ismap.cgi script or map file and you'll link whatever documents you wish to those coordinates:
This way, you'll assign different links to different coordinates of the image and when those coordinates are clicked, you'll open the corresponding linked documents.
Client-side image maps are kickstarted by the usemap attribute of the <img /> tag and defined by special <map> and <area> extension tags.
The image that is getting to form the map is inserted into the page using the <img /> tag as a traditional image, except it carries an additional attribute known as usemap. The worth of the usemap attribute is that the value which will be utilized in a <map> tag to link map and image tags. The <map> alongside the <area> tags define all the image coordinates and corresponding links.
Below is an example from the image map:
<!DOCTYPE html> <html> <head> <title>USEMAP Hyperlink Example</title> </head> <body> <p>Search and click the hotspot</p> <img src = /images/html.gif alt = "HTML Map" border = "0" usemap = "#html"/> <!-- Create Mappings --> <map name = "html"> <area shape = "circle" coords = "80,80,20" href = "/css/index.htm" alt = "CSS Link" target = "_self" /> <area shape = "rect" coords = "5,5,40,40" alt = "jQuery Link" href = "/jquery/index.htm" target = "_self" /> </map> </body> </html>
The above code will be displayed as:
Login & Study At Your Pace
500+ Relevant Tech Courses
300,000+ Enrolled Students
Don't have an account? Create your account to Start!
The Scholarship offer is a discount program to take our Course Programs and Certification valued at $70 USD for a reduced fee of $7 USD. - Offer Closes Soon!!
Don't have an account? Create your account to Start Learning!