Setting Up Hyperlinks

A hyperlink in HTML lets you 'jump' from one place in a document to another place, or to 'jump' to a different document in another location. Generally you first need to confirm the location of the document or place in the document you want to jump to, and then you can create a hyperlink to that location. In HTML the Anchor element is used to delimit a hyperlink. Before you start to put a lot of hyperlinks in your document it's a good idea to have a thorough understanding of the difference between a Relative and an Absolute address.

General Syntax for Anchors
 
<A HREF="Target Location">this is the text which will become the hyperlink</A>

This code example can be explained as follows:

<

Tag Open Delimiter

A

Anchor element

HREF

Hypertext REFerence attribute

Target Location

Value of HREF attribute. In practice, the value of this attribute will be the Universal Resource Identifier of the document which is the target of the link. This can be a Relative or an Absolute address. Please remember that, except for very specific circumstances, attribute values must be enclosed in quotation marks.

>

Tag End Delimiter

this is the text which will become the hyperlink

This is the content of the anchor, or the text which, when activated, will result in the document in the target location being loaded in your browser window.

<

Tag Open Delimiter

/

The forward slash (or solidus) indicates that this is an end tag

A

The Anchor element, when preceded by a solidus, indicates an end anchor tag.

>

Tag End Delimiter

Beyond this point it is a good idea to understand the difference between a Relative Address and an Absolute Address. If you understand that difference, using a relative address here is how to create a hyperlink to a different document in the same directory:

<A HREF="DocumentName.html">Link Text</A>

To create a hyperlink using a relative address, to a different document in a different directory in the same branch:

<A HREF="DirectoryName/DocumentName.html">Link Text</A>

To link to a directory contained within the Parent Directory, use the ../ indicator in relative addresses. This can be repeated as many times as necessary to target the appropriate parent directory:

<A HREF="../../Directory1/Directory2/DocumentName.html">Link Text</A>

To create a link to a document located on a different server, use an absolute address:

<A HREF="http://server.name.net/Directory/Path/DocumentName.html">Link Text</A>
 
Named Anchor Point -- A place to jump to within a document

To create a named point in your document that can be linked to, use the following code construct:

<A NAME="AnchorName">Optional text which can be linked</A>

This will create an invisible point in your document called #AnchorName, which can be referenced from a link in the same document, or in other documents. The link text is optional. If text is enclosed within the named anchor point, that text will load at the top of the browser window.

Linking to a Named Anchor Point

To create a hyperlink to a named anchor point in the same document, use the following code construct:

<A HREF="#AnchorName">Link Text</A>

To create a hyperlink to a named anchor point in a different document in the same directory on the same server, use the following code construct:

<A HREF="DocumentName.html#AnchorName">Link Text</A>