Share this Page URL

Chapter 5. Making the Jump to Hyperspace... > Getting Hyper: Creating Links in HTM... - Pg. 56

Making the Jump to Hyperspace: Adding Links 56 When would you ever use such a link? Most of your HTML pages will probably be short and sweet, and the web surfers who drop by will have no trouble navigating their way around. But if, like me, you suffer from a bad case of terminal verbosity combined with bouts of extreme long windedness, you'll end up with web pages that are lengthy, to say the least. Rather than force your readers to scroll through your tomelike creations, you can set up links to various sections of the document. For example, you could then assemble these links at the top of the page to form a sort of "hypertable of contents." Internal links actually link to a special version of the <A> tag--called an anchor --that you've inserted somewhere in the same page. To understand how anchors work, think of how you might mark a spot in a book you're reading. You might dog-ear the page, attach a note, or place something be- tween the pages, such as a bookmark or your cat's tail. An anchor performs the same function: It "marks" a particular spot in a web page, and you can then use a regular <A> tag to link to that spot. I think an example is in order. Suppose I want to create a hypertext version of this chapter. (As a matter of fact, I did! Look for the file named chapter5.htm on this book's CD.) To make it easy to navigate, I want to include a table of contents at the top of the page that includes links to all the section headings. My first chore is to add anchor tags to each heading. Here's the general format for an anchor: <A NAME="Name"></A> As you can see, an anchor tag looks a lot like a regular link tag. The major difference is that the HREF attribute is replaced by NAME=" Name "; Name is the name you want to give the anchor. You can use whatever you like for the name, but most people choose relatively short names to save typing. Notice, too, that you don't need any text between the <A NAME> tag and the </A> end tag.