HTML – Hyperlinks

The H in HTML stands for Hyper,but what does that mean?

Hypertext is text which can link to other files, this is called a hyperlink. A hyperlink is composed of two parts, the anchor and the destination.

<a href=”http://www.google.com”>Google</a>

In the example above the anchor tag <a></a> is used to set an object (text or image) as an anchor, in this case Google. The href attribute is used to identify the destination of the link, in this case http://www.google.com. This is called an external hyperlink as the destination is on another server. If you were linking to a file on the same server then the internal hyperlink would be.

<a href=”page1.html”>Page 1</a>

The anchor tag can be placed around other HTML elements such as images.

<a href=”http://www.google.com><img src=”googleLogo.png”></a>

This would place a border around the image indicating that it is an anchor.

You can specify where to open the linked document using the target attribute.

Value Description
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window

So if you want the Google link above to open in a new tab you would change it to.

<a href=”http://www.google.com” target=”_blank”>Google</a>

Leave a Reply

Your email address will not be published. Required fields are marked *