Directing a text link to a different part of the same page

How do I go about having a text link direct the viewer to the part of the same page where that specific information can be found so that viewers do not have to do a lot of scrolling before reaching the desired info? Thanks.
 

smoovo

New Member
Example:

The link...
HTML:
<a href="#spot">Spot</a>

The spot on the page... The <div> can be also <h1> or something else...
HTML:
<div id="spot">...Content...</div>

This will do the job.
 

PixelPusher

Super Moderator
Staff member
Example:

The link...
HTML:
<a href="#spot">Spot</a>

The spot on the page... The <div> can be also <h1> or something else...
HTML:
<div id="spot">...Content...</div>

This will do the job.

This will work, or the traditional method:

Use a link to jump to a named section
HTML:
<a href="#anchor">Goto Page Anchor</a>
Set the anchor name
HTML:
...
<strong><a name="anchor">Anchor</a></strong>

NOTE: It is not required that you insert text into the anchor, just that you name it the same in the href and name attributes. Anchors cannot be self closed (i.e "<a name="test" /> ); it will not validate.
 

PixelPusher

Super Moderator
Staff member
I'd go with smoovo's method as the name attribute is limited. Can't be applied to divs.

-Lou

Just for the sake of discussion :D, your are right, the name attribute cannot be added to a div element...but you can add an anchor right before the div or immediately inside of it. Like so:

HTML:
<a name="Lou"></a>
<div>....content...</div>

OR

<div>
   <a name="Lou"></a>
   ....content....
</div>
 

Angus

New Member
How do I go about having a text link direct the viewer to the part of the same page where that specific information can be found so that viewers do not have to do a lot of scrolling before reaching the desired info? Thanks.

I'm posting my question onto the end of this old thread, because this IS a good fit.

I have a page where I inserted named anchors (using the ID tag FWIW). They work great: I click the link, page jumps to named anchor at the top.

But when I scroll back to the top of the page (or anywhere else) and hit refresh, the page jumps BACK to the named anchor*. How do I make the page NOT do that?


*Refresh takes the page to the named anchor because when the link to the named anchor is selected, the anchor name is appended to the url. So when I select refresh I am asking to refresh the address in the url window, which is the address for the named anchor!
 
Top