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

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