Web Authoring: Named Links

Named Links


Ordinary links specify which document you want to go to. However, it is possible to specify which part of a document you want to go to, as well. This can be simply a different location within the document you are already reading, or it can involve loading an entirely new document and positioning you at a specific point.

For this to work, you have to have two anchors. One is, as usual, at your jump-off point. This is a reference anchor, similar to those we've already seen, but with one extra bit added to the URL. This extra bit is the name of the place within the document that you want to go to. The entire link looks like this:

<A HREF="http://www.lehigh.edu/somedoc.html#where">
Go to the place named "where"
</A>

The part following the pound sign ("#"), which in this case is the name "where", is the name of the location within the document ("somedoc.html") that you are linking to. But for this to mean anything, the place named "where" has to have been marked. This is where the second anchor comes in. This is called a named anchor, and it looks like this:

<A NAME="where">
This is the place named "where"
</A>

Notice that it isn't going to take you anywhere--this part is just the street sign telling you where you are.


The reference anchor that is used to link to a named anchor doesn't have to include the name of the document, if the link is just pointing to a place within the same document (this is another case of a partial URL, of which we discussed several other types on Day 1). In this case, the reference anchor just looks like this:

<A HREF="#where">
Go to the place named "where"
</A>

To see examples of this in action, check out the glossary from Day 1. It contains an "index" of terms at the top of the page: clicking on any of these will take you directly to the term, further down on the same page. The index items are all reference anchors; each term has a corresponding named anchor marking the place to jump to. You can use the "View Source" feature to see how it's all done.


 Home
SDR, 11 Aug 1995.