Forum Moderators: mack

Message Too Old, No Replies

How to use anchors

         

koocw

8:35 am on Apr 6, 2004 (gmt 0)

10+ Year Member



How do you use anchors? I think they are links to the same webpage and have something to do with the # character, but what is the exact HTML?

Any examples would be greatly appreciated.

onemoren

8:58 am on Apr 6, 2004 (gmt 0)



Yes anchors can be used as links to the same page. But in general they are links to a specific line in any page. That means if you click a link like this

<a href="page.html#anchorname">goto foo on page</a>

your browser will take you to page.html and automatically scroll down to the line where the anchor is defined by

<a name="anchorname">foo</a>

More information ... [w3.org]

pmkpmk

9:07 am on Apr 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually I think the usage via ID-tags is the more commonly used. The linking stays the same:

<a href="page.html#anchorname">goto foo on page</a>

but the target does not need to be in an <a></a> tag but can be ANY tag. Examples:


<H1 id="anchorname">foo</H1>
<P id="anchorname">foo</P>
<TABLE id="anchorname">table stuff in here</TABLE>