Creating Links
Contents:
What Are Links?
Hypertext links allow your page to point to other places on the
Internet. When the link taken it will take the person to that place.
Back to Contents
Creating Links
To create hypertext links you must use the anchor tag, <a>. The
anchor key is different from most tags because it is longer than most of
the others. The full link is in the form of <a
href="address">what you want to appear on the
screen</a>. So if you wanted to create a link that went to the
CCN Homepage your link would like this:
<a href="http://www.chebucto.ns.ca/">Chebucto Community Net</a>
Where http://www.chebucto.ns.ca is the address for the Homepage and
Chebucto Community Net is what will appear highlighted as a link on the user's
screen.
Now the http:// tells the computer that this is a hypertext link (http
stands for HyperText Transfer Protocol), which means that the location is on
the World Wide Web.
Other types of links are:
- file transfer protocol
- ftp://
- gopher
- gopher://
- telnet
- telnet://
Note that gopher is rarely used anymore, and ftp is being phased out by
the web.
All of these would then have an address following them.
So a ftp link could be:
<a href="ftp://sunsite.unc.edu/">Sunsite</a>
A gopher link could be:
<a href="gopher://ac.dal.ca:70">Dal's Gopher Server</a>
Telnet can be very useful though. It allows you to log into another
server on the Internet. So if you were at a university and had an account
there you could still get back to CCN and log into your
account by using:
<a href="telnet://chebucto.ns.ca/">CCN</a>
Try this now:
Telnet to CCN
You could even use a friend's account to then log on to your CCN
account and make changes to your files.
Back to Contents
Mailing Links
You could also create a link that sends an email message to someone.
To do this you would create a mailto link:
<a href="mailto:email address">screen text</a>
Where you would put whatever email address you wanted into that spot.
Back to Contents
Relative Links
A useful thing with links is that you don't have to supply the whole
address if the document is on the same site. If this is the case then you
can just give the link relative to the page your on. So if in your
public_html directory you had a hobbies directory that had a rock
climbing site called rock.html then you could link this to your Homepage
just by using the link:
<a href="hobbies/rock.html">Rock Climbing</a>
Instead of having to have the link:
<a
href="http://www.chebucto.ns.ca/~username/hobbies/rock.html">Rock
Climbing</a>
(Note that not only is the second link much longer, it also slows down
the system more when you follow that link)
The path for the directory above the directory you are in is
".." so if you were in the rock climbing page (in your hobbies
directory) and wanted to make a link back to your Homepage you could just use
the link:
<a href="../Profile.html">My Homepage</a>
Back to Contents
Named Anchors
In long documents such as this one it can be useful to have a table
of contents at the beginning that allows the user to jump to different
parts of the document. This is very similar to a hypertext link so it
isn't much more difficult.
Normally when you set up a link <a
href="document.html">Document</a> it takes you to the
top of the document, but by using named areas it is possible make links to
that document that go to specific parts, or to put a table of contents at
the beginning of the document that lead to the different parts of the
document.
In the document that has the section you need to use the
anchor tag like this:
<a name="Section">Section Title</a>
You can make the section anything, but it is usually an abbreviation of
the section title for convenience. The section title is what appears on
the screen at the beginning of that section so you may want to format the
link to add emphasis or to change the size of the title like this:
<h2><a name="zilla">Godzilla
Movies</a><h2>
This way the title "Godzilla Movies" will appear emphasized.
Then to link to that spot you just have to add #section to the link
to that document. So if the section "Godzilla Movies" was in a
document called movies.html then the link would be:
<a href="movies.html#zilla">Godzilla Movies</a>
If there was a table of contents at the beginning of the movies.html document
then the link could just be:
<a href="#zilla">Godzilla Movies</a>
To see more examples of this kind of link you can just hit \ (in lynx) to
view the html of this document.