The address for this web page is:   http://fishcaro.crosswinds.net/day_11_links_within_documents.htm
On to the next lesson!
Back to the COURSE SYLLABUS

11. LINKS WITHIN DOCUMENTS

(Move the cursor... how do you like the neat "fade-away cursor trail"? Visit www.dynamicdrive.com to get this fun script, and lots of others!)

When you link to a page with the

<A HREF="URL"> clickable area </A>
construction, the browser displays the top of the page. This is annoying if the item you want is a long ways down. Today's lesson tells you how to go to a particular place within a document.

INDEX CARD #11:

LINKS WITHIN DOCUMENTS (11a)

If you want to go to a particular place in a document, then you must do two things:
  1. FIND THE PLACE you want to go to, and give it a NAME. (This is called "naming a fragment." The "fragment" is the place you want to go to; you assign this fragment a name.)
  2. Give the instructions: "Go the place that I've named." (This is called "linking to the fragment.")

How do you accomplish step #1? That is, how do you NAME A FRAGMENT?
Use the NAME attribute inside the anchor tag, as follows:

<A NAME="NAME_OF_FRAGMENT"> FRAGMENT_BEING_NAMED </A>

Try to keep your NAME_OF_FRAGMENT fairly simple. Here's an example:

<A NAME="idiom_bird_worm"> The early bird catches the worm. </A>

Anchors that use the NAME attribute are called NAMED ANCHORS.

LINKING TO A FRAGMENT (11b)

How do you accomplish step #2? That is, how do you LINK TO THE FRAGMENT? Use the familiar anchor construction, with a little twist: you now need to give the name of the fragment you want to go to within the document. Do this by putting the hash symbol (#) after the Uniform Resource Locator, followed by the name of your fragment, like this:

<A HREF="URL#NAME_OF_FRAGMENT"> clickable area </A>

If you're linking to a place in the same document, then you don't need the Uniform Resource Locator. All you need is the #NAME_OF_FRAGMENT part:

<A HREF="#NAME_OF_FRAGMENT"> clickable area </A>

Printable version of Index Card 11a

Printable version of Index Card 11b

WORKSHEET #11:

ASSIGNMENT #11:

On to the next lesson!
Back to the COURSE SYLLABUS
© 2000 Carol J.V. Fisher    All Rights Reserved