homepage Welcome to WebmasterWorld Guest from 54.226.230.76
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
href="#" not linking to top of page in safari 3
vikasvrao




msg:3974357
 6:34 pm on Aug 18, 2009 (gmt 0)

Hi guys,
I'm using a simple <a href="#">top of page</a> to lead users back to the top of the page(this is part of a FAQ page).

I'm not sure why its not working on safari 3, I've tested it on IE, firefox and safari 4 and it works fine.

Please help.

 

vikasvrao




msg:3974421
 8:07 pm on Aug 18, 2009 (gmt 0)

I added this to the top of the page:
<body>
<a name="top"></a>

Then changed my href's to:
<a href="#top">top of page</a>

This works :)

tedster




msg:3974446
 8:38 pm on Aug 18, 2009 (gmt 0)

That's exactly right - I'm glad you figured it out.

encyclo




msg:3977412
 10:19 pm on Aug 23, 2009 (gmt 0)

A simpler method (and much better than using the old-style
name attribute on an anchor) is to use an id attribute on the body element:

<body id="top">

The links will work the same: <a href="#top">top of page</a>

D_Blackwell




msg:3977521
 3:47 am on Aug 24, 2009 (gmt 0)

A simpler method (and much better than using the old-style name attribute on an anchor) is to use an id attribute on the body element:

<body id="top">

My vote for tip of the day.

W3C - Anchors [w3.org]

The destination anchor of a link may be an element within an HTML document. The destination anchor must be given an anchor name and any URI addressing this anchor must include the name as its fragment identifier.

Destination anchors in HTML documents may be specified either by the A element (naming it with the name attribute), or by any other element (naming with the id attribute).

I admit to having a lot of old websites or pages that still have a lot of:

<p>
<a name="bad-example">
</a>
</p>

but I also still run into a lot of people that still using this sort of markup.

id="best-practice" is my friend.

Used to have to wrap the fragment identifiers in a <p> because pages wouldn't validate if one just slid the <a> in the page; though they worked.

rocknbil




msg:3977991
 10:04 pm on Aug 24, 2009 (gmt 0)

This thread really needs to be linked to P1R's Fragment Identifers [webmasterworld.com] thread . . . "named anchors" or fragment identifiers can be attached to any id'ed element.

Receptional Andy




msg:3977993
 10:10 pm on Aug 24, 2009 (gmt 0)

I think the reason for the <a name> hangover is that it was not widely supported when fragment identifiers were introduced. Thus, the non-ideal situation of a new element just for the sake of a skiplink that was widely compatible.

SuzyUK




msg:3978002
 10:51 pm on Aug 24, 2009 (gmt 0)

apparently linking to #top,
<a href="#top">link to top</a> - works without even attaching (name=top or ID = "top") to any element, via ID or name ;)

it's a kinda special reserved name thing...

koan




msg:3978020
 11:33 pm on Aug 24, 2009 (gmt 0)

Some browsers link to the top of the page by default if you have <a href="#"></a>, so if it doesn't find #top, maybe it just fall back to the default # behavior.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved