W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > January to March 2004

Re: id and name should be unique (was: RE: anchors and Bobby)

From: Jon Hanna <jon@hackcraft.net>
Date: Thu, 22 Jan 2004 14:53:10 +0000
Message-ID: <1074783190.400fe3d6bba66@82.195.128.192>
To: "w3c-wai-ig@w3.org" <w3c-wai-ig@w3.org>

Quoting "Jewett, Jim J" <jim.jewett@eds.com>:

> An attribute of type ID is supposed to be unique to the
> document.  I realize that "name" and "id" are different
> attributes, but realistically ... the real reason this seems 
> to work is just that most browsers don't actually
> enforce uniqueness.  

You are correct, the id and name attributes on <a> elements share the same
namespace and my suggestion was incorrect (lucky, then, that I haven't bothered
to stay compatible with browsers that don't support id for some time, I would
have been doing it wrong).

> 	<p id="intro" name="intro">text</p>
> 
> would be better, except that old browsers probably
> won't see the name on anything but <a></a>.  

name isn't allowed on <p> elements. Also other uses of name are quite different
from the use of name on an <a> element, for example name has no connection to
id on a form input and they can safely differ (and in some cases must).

> Perhaps it would make sense to use a convention,
> such as prepending "start" to the id when 
> creating the otherwise useless target anchor.
> 
> 	<p id="intro"><a name="startintro"></a>
> 	text</p>
> 
> Then #startintro would be used when you want a
> point target (as with navigation), but #intro 
> would be used for actions (like CSS) that apply to 
> the entire section.

I would prefer to still use id on the <a>  hence, having a choice between
maintaining backwards compatibility thus:

<p id="intro"><a id="startintro" name="startintro"></a>
text</p>.

Or to abandon it thus:

<p id="intro">text</p>.

--
Jon Hanna
<http://www.hackcraft.net/>
*Thought provoking quote goes here*
Received on Thursday, 22 January 2004 09:53:12 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:13:31 UTC