Learning HTML
Chapter 4 - HyperText Links

4.4 Links to Specific Sections in Documents

Up to now, we've seen how to create links to other documents using both absolute and relative references. You can also create hypertext links to sections within documents. The first step is to create a named section using the anchor tags ( <A> </A> ) with the parameter NAME (instead of HREF). For example, the heading to this section uses the following tag:

 <A NAME="sections">Links to Specific Sections in Documents</A>

In order to create a link to this section within this document, you would use HREF with a hash mark ( # ) followed by the section name. If you wanted to provide a way to go back to the heading at the top of this page, the link would be:

 Go back to <A HREF="#sections">top of page</A>.

Selecting that link would take you to the top of this document. Want to try it? Go back to top of page.

You can also use this to go to specific sections of other documents. If you wanted to link to the heading of this page from another document, the link would look like this:

 Go to <A HREF="chap4/4.html#sections">top of chapter 4.4</A>

Selecting that link would take you to Part 2 of the guide (the file 4.html , which is a relative reference) and then go to the section named view.

When creating named sections, be careful with your spelling and case. These references can be case sensitive!


Learning HTML
www.dickinson.edu/~dempsey
Last updated 6/8/2001
Copyright © 2001 Paul Dempsey