Linking to Named Anchors


To link to a named anchor, you need another anchor tag, only this one should be a source anchor, not a destination anchor. In the href attribute of the source anchor, type a number sign (#) followed by the name of the anchor to which you want to link, like this:

 <ol>   <li><a href="#question01">What is the meaning of life?</a></li>   <li><a href="#question02">What is the meaning of money?</a></li>   <li><a href="#question03">What is the meaning of time?</a></li> </ol> 

These anchor tags appear as regular hyperlinks in the browser. That's because they are regular hyperlinks. The only difference is that they go to named anchors on the same page, not to the top of some other page.

FAQ

If a named anchor is invisible, how does the browser show that the visitor has jumped to one?

Normally, when the browser jumps to a named anchor, it scrolls the screen so that the anchor point is at the top.


What happens if you want to link to a named anchor that exists on some other page? Not a problem. Simply tack the named-anchor nomenclature to the end of the path, like this:

 <a href="../movies/movies.htm#newrelases">New Releases</a> 

This hybrid path finds the page movies.htm and then jumps to the newreleases named anchor on this page.

TIP

It's good etiquette to include a Back To Top link somewhere after the named anchor. This way, the visitor can return to the source of the link quickly and easily.

You can accomplish this with another named anchor. By way of example, assume you're building a FAQ page. Right before the list of questions, insert a named anchor called top. Then, after the answer to each question, add code to this effect:

 <a href="#top">Back to the top</a> 




Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net