Embedding an Image in a Hyperlink
Description
A common use of the img
element is to
create an image-based hyperlink in conjunction with the a
element.
Example
The following code shows how you can use the img
and a
elements together.
<!DOCTYPE HTML>
<html>
<body>
<p>
<a href="http://java2s.com/page.html">
<img ismap src="http://www.java2s.com/style/download.png"/>
</a><!--from www . j av a2 s . c o m-->
</p>
</body>
</html>
Note
If you apply ismap
attribute to the img
element,
you create a server-side image map, which means that the position you clicked on
the image is appended to the URL.
For example, if you clicked 4 pixels from the top and 10 pixels from the left edges of the images, the browser will navigate to the following:
http://java2s.com/page.html?10,4