Welcome to WebmasterWorld Guest from 54.158.10.156

Forum Moderators: incrediBILL

Message Too Old, No Replies

Named anchor - proper usage?

     
4:33 am on Oct 9, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2006
posts:2154
votes: 3


If I use named anchors to jump around the single page, and I have few of them on the top like:

<a href="#general">General</a>


how would you use the named anchor code?

<h3><a name="general">General</a></h3>


or

<a name="general"></a>
<h3>General</h3>


The first one is bit confusing for me as it renders like a link while it does nothing when you click on it. I think that could confuse the user. On other side I see it used in HTML examples and wonder about right usage.

Thanks
11:10 am on Oct 9, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Aug 9, 2008
posts: 961
votes: 0


Hi smallcompany,
Is there a reason you can't use: <h3 name="general">General</h3>
Or better, as name has been deprecated in favour of id: <h3 id="general">General</h3>
If you must support name, then a lot of coders use: <h3 name="general" id="general">General</h3>
12:30 pm on Oct 9, 2010 (gmt 0)

Senior Member from CA 

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

joined:Aug 31, 2003
posts:9068
votes: 4


There is no reason to use the
name
attribute these days, so the use of
id
is the way to go:

<h3 id="general">General</h3>
11:02 pm on Oct 9, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Aug 9, 2008
posts: 961
votes: 0


@smallcompany.
There are good explanations for the reasons you see those code snippets at sitepoint:
id = [reference.sitepoint.com ]
and href=[reference.sitepoint.com ].

That said, if you have no reason to support name, I'm with encyclo on just using an id on your header - it's valid and works.

However, that still leaves the usability problem with user agents that will not change focus. Rather than loading up the code with dummy links as in the examples you've referred to (and the ones at sitepoint), I'd suggest using tabindex - it is designed to address this exact issue.

@encyclo Thanks for causing me re-think my initial post
12:33 am on Oct 10, 2010 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


...and wonder about right usage.


Honorabel mention on fragment identifiers [webmasterworld.com]
7:37 pm on Oct 12, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2006
posts:2154
votes: 3


Thanks.

I wonder why Dreamweaver CS3 does not recognize the ecyclo's suggested way. I see a sole ID right in H tag (or any tag) works fine when I test it in FF or IE8. Yet, not seeing it in design view while developing may pose a problem if the site is more then simple and with lot of pages.

tabindex unfortunately does not work with the mouse.
10:52 am on Oct 13, 2010 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10553
votes: 12


more on the subject from p1r...

Fragment Identifiers aka Named Anchors:
http://www.webmasterworld.com/accessibility_usability/3996219.htm [webmasterworld.com]
4:12 pm on Oct 13, 2010 (gmt 0)

Senior Member

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

joined:Nov 28, 2004
posts:7999
votes: 0


THAT's the one I was looking for.:-)