 |     |
 |
 |
Anchors
The real point of the Web, of course, is that documents can be linked to
each other, or to other types of files such as movies or sound clips,
through the use of hyperlinks. These links allow authors to link documents
together in intuitive ways, as opposed to traditional linear texts such as
books, articles, or almost anything else printed.
In order to create a hyperlink, you'll need to know two things. The first is
the URL (that is, the location ) of the file to which you want the link
to go. The second is knowledge of how links work, which
is the subject of this chapter.
You will be required to send the html files, you produce during this session, as attachments.
The Basic Anchor
The simplest possible anchor starts with <A> and ends with </A>. However,
you will never ever use the <A> tag by itself, because it doesn't do
anything. You'll need to enhance the <A> tag with attributes like...
HREF stands for "Hypertext REFerence," which is another way of saying, "The
location of the file I want to load." Most anchors are in the form <A
HREF="URL">, where URL is the location of the resource to which you want the
link to point. For example, the CWRU Web server is at "http://www.cwru.edu/"
(that's the server's basic URL). A sentence which contained a link to that
address would look something like:
Check out the <A HREF="http://www.cwru.edu/">CWRU Web server </A>
The words outside the angle brackets but between the open and close of the anchor ("CWRU Web server") would
be displayed as a hyperlink. Selecting that link within a Web browser would
cause the browser to link to and load the CWRU Web server's main page. Here's what the
above markup looks like in your browser:
The double-quote marks found around the value of HREF in an anchor are,
under certain specific circumstances, optional. However, in most cases they
are required. In addition, if you start the URL with a double-quote, you
must close it with another. Just as tags need to be balanced, quote-marks do
too.
Linking to a local Document
Exercise:
A URL (and therefore, by implication, an anchor) can point to any resource
available on the Web. This is usually another HTML page, but it can also be
a graphic, a sound file, a movie, or any other kind of file. This fact lets
you set up links to large graphics without actually having to display them
in the page. For example, if there were a graphic file called "welcome.gif"
in the directory "emeyer" of a server with the address "www.site.edu," the
URL would be:
http://www.site.edu/emeyer/welcome.gif
Therefore, a text anchor referring to this graphic file would look something
like:
<A HREF="http://www.site.edu/emeyer/welcome.gif">See my welcome message! </A>
A user who selects the anchor thus created will cause their Web browser to
download the graphic file, which will then be displayed by their browser or by
a helper program.
- In case you were wondering, the first four letters of a Web
URL do mean something. http stands for "HyperText Transfer
Protocol," which is the technical way of saying "how the computers move Web
data back and forth."
There is of course a way to link to a specific part of a document. Using a standard
hyperlink, of course, but with a small addition. Found in the HREF attribute, the name is tacked onto the end of the URL of the document in which it appears. To do this, just enter
document's URL, and then add a hash-sign (#) and the name to the end of the
URL. For example, assuming that the document's URL is "http://www.site.edu/food.htm" the pointer to the named anchor pt.3 would be:
http://www.site.edu/food.htm#pt.3
A hyperlink which has the above URL in its HREF attribute will take the
reader straight to the text contained within the anchor <A NAME="pt.3">...
</A> within the file "food.htm." (Incidentally, if the browser loads a file
but can't find the named anchor which has been specified, it simply goes to
the top of the file, just as it would have if there hadn't been a name in
the URL at all.)
Now, you may be confused about why a hash-sign (#) is in the URL. That
hash-sign is how the browser knows that it's looking for a name, and how it
keeps the named anchor separate from the document's filename. Therefore, if
you are writing a hyperlink which points to a named anchor found within the
same document, you only need to have the hash-sign followed by the name of
the anchor. For example, a hyperlink to Part 3 which is found within the
file "food.htm" would have this markup:
<A HREF="#pt.3">Part 3</A>
training report sheet
Using the above material try to answer the following:-
|
 |
 |
 |     |