6

If my url is something like: http://www.thisisawebsite.com/page.php#about
How do i make it so when the link is clicked, it'll go to the header "about", or anywhere else i so desire?

phxvyper
  • 345
  • 1
  • 4
  • 12

2 Answers2

10

Just markup the header on the target page with the id "about" i.e.

About

That way your link on the linking page http://www.thisisawebsite.com/page.php#about will go straight to the "about" header - a h1 in this example but it could be whatever you'd given the id of "about". Remember you should only use the id "about" once on the page though.

Nicolae Maties
  • 2,214
  • 1
  • 11
  • 22
Richard Jordan
  • 7,916
  • 3
  • 36
  • 45
  • I did forget to thank you for your answer as well. I will use yours considering i found it it can be used as an attribute an pretty much all tags, while name only works with a few... – phxvyper Dec 02 '12 at 01:57
6

You need to define the anchor in your markup (near your 'About' header):

<a name="about"></a>

Anyone else having a question about this should explore using an ID attribute on the actual element they want to link to:

<h1 id="about">About</h1>
E_net4 - Krabbe mit Hüten
  • 24,143
  • 12
  • 85
  • 121
Kevin Boucher
  • 15,718
  • 3
  • 43
  • 54