In the previous section we examined the
A element, that
is used to define document links inside the document body. However,
document links often make more sense when both head and tail are entire
documents. Links of type "Next" and "Previous" are examples of this.
Attentive readers will already have guessed the right place for such
links. If you remember what we covered in the first tutorial, the place
to put information about a document is in the document head, i.e. the
Document links are indicated by use of the
LINK element has similar syntax to the
element when used as a hyperlink head - i.e. it accepts the
REV attributes, with one exception:
LINK is an
empty element. As you probably remember, empty elements have no
content and no end-tag. Thus it is imperative that we include the
TITLE attribute in our links to give some indication of
what the linked resource is. Here are some examples:
<HEAD> <TITLE>Transfirbulation Technology - Chapter 2</TITLE> <LINK REV="Chapter" HREF="../" TITLE="Transfirbulation Technology"> <LINK REL="Contents" HREF="../toc.html" TITLE="Transfirbulation Technology - Table of Contents"> <LINK REL="Glossary" HREF="../glossary.html" TITLE="Transfirbulation Technology - Glossary"> <LINK REL="Copyright" HREF="../copyright.html" TITLE="Transfirbulation Technology - Copyright Notice"> <LINK REL="Author" HREF="email@example.com" TITLE="Dr. Arnold D. Propellerhead"> <LINK REL="Start" HREF="intro.html" TITLE="Transfirbulation Technology - Introduction"> <LINK REL="Next" HREF="chapter3.html" TITLE="Transfirbulation Technology - Chapter 3"> <LINK REL="Previous" HREF="chapter1.html" TITLE="Transfirbulation Technology - Chapter 1"> </HEAD>
Notice how a document's head can contain a wealth of useful information on the document. The above example:
- Identifies the document through a unique title
- Indicates that it is a chapter of a book and points to the book
- Points to the table of contents for this book
- Points to a glossary of terms appearing in this document
- Points to the copyright notice governing this document
- Points to the author of the document
- Points to the first document in the series this document is part of
- Points to the next document in the series
- Points to the previous document in the series
Our document, which was originally just a stand-alone piece of text
with no relationship to anything whatsoever, has suddenly become the
integral part of a book with links to all the relevant sections. The
usefulness of such information is immediately obvious - the book can now
easily be read through by following the
Next links, the
table of contents can easily be found, the copyright notice is clearly
indicated, the author can be contacted, and so on. That's the good news.
Now comes the bad news. Like many interesting features of HTML and
LINK element remains unimplemented in the most
popular browsers, most notably Netscape Navigator and Microsoft Internet
Explorer. These browsers will ignore
LINK elements when
they encounter them (with a few exceptions, but these refer to
stylesheets, which we will cover in a future tutorial). This is quite
LINK has been part of the HTML
specification for years now, and also considering the fact that most
HTML authors resort to providing links within the body of the document
for analogous puroposes - if you look at this tutorial page, for
instance, you'll find links in the body of the document for the next and
previous sections, index, table of contents, home, author, copyright
notice etc., that are placed all over the page and cannot be easily
located. However, document links are still very useful. First, in the
hope that they are widely implemented, it is useful to have them.
Second, they are very useful for organizing your documents. Third, they
are recognized by most popular search engine robots that will find it
easy to traverse your entire site if it is linked with these elements.
Fourth, there are some browsers (such as Lynx and Mosaic) that do
support them and create toolbars when viewing pages that allow users to
follow these links. In the spirit of always authoring proper HTML first
and worrying about specific implementations later, I recommend that you
use document links in abundance in all your documents.
This brings us to the interesting topic of link types. We have already looked at various link types that are in wide use. However, little effort has been made to standardize these names in the past years. The examples I have used above are some of those recommended by the HTML 4.0 Specification. In addition, some other link types are recommended by the specification. These are:
- Specifies an alternate version of the document, such as a translation or an alternate format.
- This indicates a stylesheet that can be applied to the document to affect its presentation. This is the only link type recognized by the two popular browsers.
- Similar to Chapter, this indicates a Section of a body of work.
- As above, for a subsection.
- As above, for an appendix.
- Indicates a document that contains Help for using or viewing the current document.
- Indicates a "bookmark" within an extended body of work, which is an important point in it that doesn't necessarily fall under one of the other categories.
- Although not part of the recommendations in HTML 4.0, this widely used link type is used to refer to the next upper level in a hierarchy of documents like the one used on WebReference.com (for instance "Up" relative to /experts/html would be /experts)
I encourage you to use these link types, as well as others that make sense to you. In the end, it doesn't matter if some non-standard link types are used, since they will usually need to make sense primarily to a human. Try to use these link types as much as possible, and add any special ones that you might see fit to add.
Well, that's the basics on links in HTML. Let's see how far we've gone. You now know how to:
- Create an HTML document
- Create the basic elements that define the global strucure
- Create headings and paragraphs
- Refer to resources using URIs
- Create hyperlinks in the document body and head
...and that's no small feat. You are now equipped to create reasonably complete HTML documents for many applications.
I've been quite technical for this tutorial, so for the next one we'll relax a bit and have a look at a few more useful elements, both for marking up blocks of text that aren't headings or paragraphs, and for marking up phrases within such blocks of text, something we haven't seen so far. Watch this space for the next tutorial, that will be coming your way on June 25.