I'm sure everyone is familiar with the concept of links so I'll just get right into how to use them.
There actually is no tag called the link tag. Hyperlinks are made by setting the href
attribute of the anchor tag.
The anchor tag looks like this <A></A>
.
The href
attribute can take two different types of arguments; relative addresses and absolute
addresses. The example below is a relative address. It links to a file called 'index.html' in the
current directory. To link to a file in a directory above the current one just add the name of the
folder before the filename. ie. 'folder/index.html'. To link to a file in a directory below the
current directory use the '../' option. ie. '../index.html'
<A HREF = "index.html">
This is the link to the index page
</A>
The example below is of an absolute address. These are used when linking to a completely different
webpage. Relative links are generally used when linking to pages within your own website.
<A HREF = "http://www.google.com">
This is the link to Google
</A>
The anchor tag also has another function besides hyperlinks between webpages. It is also used to
create anchors within a webpage to link other areas of the same page. To do this you place anchor
tags in the locations you wish to jump to within your webpage and set the name
attribute.
Then you create a hyperlink to that anchor. Below is an example.
<!-- I have placed this anchor at the top of this page -->
<A NAME = "#top">
<A HREF = "#top">
This links to the anchor tag at the top of this page
</A>