homepage Welcome to WebmasterWorld Guest from 54.242.126.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
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

5+ Year Member



 
Msg#: 3974355 posted 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

5+ Year Member



 
Msg#: 3974355 posted 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

WebmasterWorld Senior Member tedster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3974355 posted 8:38 pm on Aug 18, 2009 (gmt 0)

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

encyclo

WebmasterWorld Senior Member encyclo us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3974355 posted 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3974355 posted 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

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3974355 posted 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#: 3974355 posted 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

WebmasterWorld Senior Member suzyuk us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3974355 posted 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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3974355 posted 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