SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: To Top Of Page

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    To Top Of Page

    Whats another way I can jump my page from the bottom of the page with a "Back to Top" link without adding an empty #top div right after the body? Is there any way to do this without adding an extra div? I can probably add an id to the body but would want to avoid that if possible

  2. #2
    SitePoint Zealot PatrickSamphire's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to put an id on *some* element at the top of the page (or use an existing id on an element up there). It doesn't matter if it's the body, the h1 or an existing div.

    Out of curiosity, is there a particular reason why you don't want to put an id="top" on the body element?

  3. #3
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Location
    Sector R
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about just:

    Code:
    <a href="#">Back to Top</a>

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx for the replies! I tried the <a href="#"> and it does work to get to the top, but I'm using a local scroll javascript so i went with giving the body an ID and its workin perfectly

    thanks!

  5. #5
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,271
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)

  6. #6
    SitePoint Zealot PatrickSamphire's Avatar
    Join Date
    Jul 2006
    Location
    UK
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by enwise View Post
    thx for the replies! I tried the <a href="#"> and it does work to get to the top, but I'm using a local scroll javascript so i went with giving the body an ID and its workin perfectly

    thanks!
    I've found that gives problems with certain CMSs.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •