October 22, 2011

Using Image as a Link

You can make your favorite image as a link too by placing the <img> tag in between the <a> and </a> tags so that the image is in place of the text you would usually have. So, to create a link using pix.jpg that will lead to header.html, you would write the following code

<html>
<head>
<title>Images</title>
</head>
<body>
<a href="header.html"><img src="images/pix.jpg" alt=”pix” 
title="pix description" border="5" /></a>
</body>
</html>

The code will be rendered by the browser this way:


About the code:
  • The <a href=””>…</a> element is used in creating links.
  • The <img /> tag is used to insert image.
  • The border attribute is used to control the thickness of the border around the image.

1 comments:

Lalah said...

thanks so much for this :)