HTML Hyperlinks

Example: Contents of this document

Hyperlinks

Hyperlinks allow you to point at something else at the Internet. For instance, a hyperlink can be a pointer from one HTML-document to another one, somewhere on the Internet. Clicking on the pointer, makes that the indicated document is loaded in your browser.

Example 1

The underlined word Research Departments is a hyperlink to the research departments of FNWI, and points to a file at the location http://www.science.uva.nl/research/departments.html. If you click on it, the HTML file is displayed by the browser. The HTML code for this hyperlink is

<A HREF="http://www.science.uva.nl/research/departments.html">Research Departments</A>

Example 2

A hyperlink can also be a pointer to a particular file on a ftp-site. The underlined words Maple share library are a link to a file pub/maple-ftplib/5.3/share.tar.Z at the WMI ftp site. If you click on it, you can specify a name to save the file on your disk. The code used is

<A HREF="ftp://ftp.maplesoft.com/pub/maple/share/5.5/share.tar.Z">Maple share library</A>

URL's

In both examples we have to specify the location of a file on a remote host, but also a protocol, like http or ftp. A universal resource locator (URL) is the uniform way of denoting something on the internet, and it consists of a protocol, a host and a location.

protocol
The hypertext transfer protocol (http) is the protocol used by WWW for HTML-documents. The file transfer protocol (ftp) is an other Internet protocol to exchange files between computers. The reaction of the browser depends on the protocol used.
host
The first part of the string denotes the remote host computer. The computer www.intbc.com should be a WEB-server if the http-request is to work, and the computer ftp.science.uva.nl must be a ftp-server if a ftp-request is to work. Sometimes, you have to specify a port on the host as well. For instance, www.science.uva.nl:8000, is the port 8000 at this machine. Default port number for the http-protocol is 80.
location
The location of the file is specified relative to the root. This is a distinct location in the file system on the server which is known to the protocol.

The reaction of the browser depends on the protocol used. The hypertext transfer protocol (http) is the protocol used by WWW for HTML-documents. The file transfer protocol (ftp) is an older Internet protocol to exchange files between computers. Example:

http://www.science.uva.nl/research/departments.html

ftp://ftp.maplesoft.com/pub/maple/share/5.5/share.tar.Z

A strict definition of a hyperlink is the following: a hyperlink is a pointer from a document to a URL.


Anchors

An anchor is a location in a textual document to which a hyperlink can point. For instance, a section of a document can make a good anchor. If we specify a document without an anchor, we arrive at the beginning. The browser will usually not display the anchor. To make an anchor called "TestAnchor" exactly here, you type

<A NAME=TestAnchor>here</A>

A reference "TestLink" to this location is made by appending to the URL a cross # and the name of the anchor.

<A HREF="theURL#TestAnchor>TestLink</A>

Example: Contents of this document

This is made by the code

<H4>Example: Contents of this document</H4>

<UL>
<LI><A HREF="#Hyperlinks">Hyperlinks</A></LI>
<LI><A HREF="#URL's">URL's</A></LI>
<LI><A HREF="#Anchors">Anchors</A></LI>
</UL>

While the sections have a form like

<H3><A NAME=Hyperlinks>Hyperlinks</A></H3>

Back Back to HTML Course Contents