HTML Links

The element, or anchor element, is used to create a hyperlink to another webpage or another location within the same webpage. The hyperlink created by an anchor element is applied to the text, image, or other HTML content nested between the opening <a> and closing </a> tags.

The link address is specified in the “href” attribute. See the example below:

<a href="http://www.techguruspeaks.com">Click here!</a>
See more coding examples below.
 

Example 7 [Creating text links to other pages]:-

On clicking the 1st link it will take us to the page 01.html; whereas on clicking the 2nd link we will be redirected to the web page named 02.html.

<html>
<body>

<p>
<a href="01.html">
This text</a> is a link to a page on
this 1st Web site.
</p>

<p>
<a href="02.html">
This text</a> is a link to a page on
this 2nd Web site.
</p>

</body>
</html>

 

Output:

 

Example 8 [Creating image links to other pages]:-

The following example shows that on clicking the image link it will take us to the web page named 02.html.

<html>
<body>
<p>
You can also use an image as a link:
<a href="02.html">
<img border="0" src="buttonnext.gif" width="65" height="38">
</a>
</p>

</body>
</html>

Output: