By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,648 Members | 1,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,648 IT Pros & Developers. It's quick & easy.

jump to top of page

P: 16
I am trying to get a link back to the top of the page I'm on.

For the anchor, I've got
Expand|Select|Wrap|Line Numbers
  1. <a name="topofpage" id="topofpage"></a>
and for the link I've got
Expand|Select|Wrap|Line Numbers
  1. <p><a href="#topofpage">back to the top</a></p>
It works (or maybe it doesn't work!) in IE6/Win and IE5.2/Mac, but in Safari it will only take me right back to the top of the page if I put the anchor tag in the <body> and before the first <div>. If I put it inside an existing <div> the link takes me back to below the top of the page. If I create a separate <div> for it or put it inside <p> tags it throws out the layout. But the page fails validation for XHTML strict if the anchor goes within the <body> tag.

Am I using the correct syntax or should it be done differently if I'm using CSS/XHTML? (My experience up until now has been HTML only.) Or have I missed something?

I can post the code for the whole page if that will help.

Thank you.

Helen
Jan 26 '07 #1
Share this Question
Share on Google+
3 Replies


drhowarddrfine
Expert 5K+
P: 7,435
Yes, that should work.
Jan 26 '07 #2

P: 16
I don't understand what you mean by "that should work", because it doesn't work in Safari unless I put the anchor just inside <body>, and that won't validate.

If I put the anchor tag inside a <div> or <p></p>, following the link doesn't take me right back to the top but a bit below it.

Is there some other way of doing this?

Thank you.

Helen
Jan 26 '07 #3

drhowarddrfine
Expert 5K+
P: 7,435
You said it works in IE6 and the Mac. I say it works in Firefox and IE7. So it should be working in Safari but I don't know why it doesn't. I don't have Safari but others here do. Post your code or a link so we can look at it.

I have a feeling there might be a misunderstanding of what you mean by "top". Perhaps there is a default margin or padding around the div or body and "top" is a few more px down in Safari than other browsers?
Jan 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.