jump to top of page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wavedancer
    New Member
    • Jan 2007
    • 16

    jump to top of page

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

    For the anchor, I've got
    Code:
    <a name="topofpage" id="topofpage"></a>
    and for the link I've got
    Code:
    <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
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Yes, that should work.

    Comment

    • wavedancer
      New Member
      • Jan 2007
      • 16

      #3
      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

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        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 misunderstandin g 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?

        Comment

        Working...