Understanding Hyperlinks: Heads or Tails?
Now for the moment you've all been waiting for: an explanation of hypertext.
Hypertext is this brilliant concept someone came up with a while ago, and it went something like this: documents often refer to other things. When someone is looking at a document and he sees such a reference, he might want a quick way to get to it. So why don't we find a way of encoding it inside the document itself? This way, a bunch of related documents will be linked between each other not just by the text, but in a physical way.
The most obvious example of this is a simple book, say a technical manual. This book is divided into chapters, and each chapter is in a separate file. In addition to the chapters, there is a table of contents, an index and a glossary.
Now suppose someone is reading chapter 2. At the end, he'll want to
get to chapter 3. One way to do this is to say "well, chapter 2 was in a
chapter2.txt, I suppose chapter 3 will be in a
chapter3.txt. Let's load that." But that is not
a very good way of doing things. For one thing, names may not be that
simple, and for another, the kind of intelligence required to make such
a deduction is not possessed by today's computers - so although you can
probably figure out where the next chapter is, your computer is usually
too stupid for this.
Another problem is when you get a reference inside the chapter. For instance, you might get something like this: The Object Transfirbulation Protocol is implemented similarily to the Media Object Request Originating Name Sequencer (see Chapter 113 - M.O.R.O.N.S. in Action).
Now you, being an avid fan of Object Transfirbulation, want to know more about the related M.O.R.O.N.S. technology, which is described in the chapter about M.O.R.O.N.S. in action. But the only way to get there is to sort through all the intervening chapters. Wouldn't it be nice to be able to jump directly from that reference to the relevant chapter?
Also, suppose that for some strange reason you are so ignorant as to not know what Transfirbulation is. Obviously, you'll want to refer to the Glossary to get this information. Indeed, you find after a lot of searching that the Glossary includes the following enlightening definition: Transfirbulation: The process under which an object's non-persistent firble state is altered.
It would be useful if you could just, say, click your mouse on the word "Transfirbulation" and go directly to that part of the glossary.
Imagine, as well, that you came across a random chapter detailing M.O.R.O.N.S., and found it fascinating. Naturally, you'll want a way to get to the Table of Contents of the book to see what other such fascinating topics may be discussed. It would be useful if there was a way to find the Table of Contents directly from the chapter.
After you've read the chapter, imagine you're so excited that you want to e-mail the author and tell him how exciting you found his work. Wouldn't it be nice if a link to his e-mail address was in there as well?
The answer to all these problems is the use of hyperlinks. A hyperlink is a defined link from one document or part of a document to another document or part of a document.
A hyperlink needs three things to characterize it: A head, a tail and a type. The head is where the hyperlink starts from. The tail is where it leads to, and the type indicates the relation between the head and the tail. Here's how this describes the examples we discussed earlier:
|Chapter 2||Chapter 3||Next Chapter|
|Chapter 2||Chapter 1||Previous Chapter|
|"see Chapter 113"||Chapter 113||Reference|
|Transfirbulation||Definition of Transfirbulation in Glossary||Definition|
|Chapter 113||Table of Contents||Table of Contents|
|Chapter 113||Dr. Arnold D. Propellerhead||Author|
A lot of hyperlinks don't necessarily need a specific type. An example is the reference to Chapter 113 above: it's just a reference to it from a point in the text. Also, note that sometimes we might want to indicate a reverse relationship, for example, we will want to point out in the Glossary that this is a glossary for Chapter 2. This can be achieved by a link with the Glossary as the head, Chapter 2 as the tail, and a type of "Reverse Glossary," meaning that the head is the glossary for the tail instead of the other way around.
Not surprisingly, URIs are used to indicate heads and tails in HTML hyperlinks. That's the reason URIs were invented: you can link from a point in your document to another document or a part of another document by using a URI that identifies that document, or you can link to anything else, since theoretically anything can be identified using a URI. Note, however, that URIs do not have a way of specifying a specific section in the document; that's the reason we have fragment identifiers.
A fragment identifier is optionally placed after an absolute or
relative URL and indicates a section, or fragment, of the
document. It consists of a hash mark (
#) and a string which
identifies that particular fragment, like this:
The above is called a URL reference. A URL reference consists of a URL and (optionally) a fragment identifier.
This happens to point to the section of this page you're reading right now. Try giving this URL to your browser; it will probably scroll down to this section after displaying the page. There are ways to indicate which part of your HTML document corresponds to which fragment identifier. And that's what I'm going to tell you about, right after I explain element attributes.