What is a hyperlink

“An element in an electronic document that links to another place in the same document or to an entirely different document.” www.webopedia.com

The HTML tag for a hyperlink is the <a> tag closed with an ending tag </a>. The hyperlink tag must contain an attribute which specifies the file or location to be linked to, that is, href=”…”, with the URL of the page or location placed between the quotes. For example:

<a href=”http://www.mySite.com/myPics.html”>My Pictures</a>

External Links

An external hyperlink is one that when clicked will take the user to a new page within your site or to a new site. By default the new page will be displayed within the same browser window. Later we’ll look at how to specify a different or new window.

Text Links

The hyperlink tag surrounds text which is displayed highlighted and is the link that the user may click. As displayed to the user, the hyperlink looks like this:

This is a text hyperlink

… and the HTML code looks like this:

<a href=“http://www.somewhere.com”>This is a text hyperlink</a>

When the user clicks the link they will be taken to the web site www.somewhere.com. The destination is specified using the href attribute. In this example, the link is to another website and not another page within the current site, and therefore includes http://www. The link points to a domain name and not a specific page within that site. If a particular page is not specified, then the hyperlink will link to the default page for the site which should be named default.htm (an internet-wide standard).

To link to a page within your site you would simply specify the file name of the page you wish to link to, e.g. <a href=”myotherpage.htm”>…</a>. Notice that you do not need to include http://www or any folder information for a page that is saved in the same location as the current page.

Within your own site, if the page you wish to link to is located in a different folder to the current page, you will need to include the folder as well, for example:

<a href=”/myPics/myPics.htm”>My Pictures</a>

The above hyperlink will link to a page called myPics.htm in a sub-folder of the current one, called myPics.

The location of files is called pathing, and just like locating files on your computer, files on websites use the same conventions. To reference the folder above the one you are currently at, use two dots before the slash, e.g. <a href=”../default.htm”>

 
WANT TO LEARN MORE ABOUT WORKING WITH HTML PROGRAMMING CODE?
 

CLICK HERE TO SEE OUR HTML COURSE

Need Help?

Take advantage of our personalised, expert course counselling service to ensure you're making the best course choices for your situation.