W3C home > Mailing lists > Public > www-html@w3.org > July 2001

Re: On id and name attributes

From: Clover Andrew <aclover@1value.com>
Date: Mon, 16 Jul 2001 12:40:19 +0200
Message-ID: <D58B0195B58937489E89124469E57CA20D5079@EX1.1value.com>
To: <www-html@w3.org>
Bjoern Hoehrmann <derhoermi@gmx.net> wrote:

> HTML 4.01 section 12.2.3 states: "The id and name attributes
> share the same name space". Is this true for _all_ name
> attributes?

No. Each form has its own namespace for control names, and each
applet has its own scope for parameters.

> Why does this not apply to BUTTON, TEXTAREA, SELECT, INPUT,
> OBJECT and PARAM?

Multiple forms with the same control names inside (and even
multiple inputs with the same name) are necessary. Multiple
applets with the same parameter names too. This is incompatible
with being in the 'id' namespace which requires unique
identifiers. Usage of 'name' in these elements should be
entirely unrelated to the traditional usage of 'name' to define
anchors.

NB: Internet Explorer's implementation of getElementById('...')
(and document.all) will nonetheless happily return a <input
name="...">. It is worth avoiding elements with the same 'name'
as another element's 'id' for this reason. Tch.

> Why 'id = name'? It is defined as ID in the DTD

True! Is this a mistake?

-- 
Andrew Clover
Technical Consultant
1VALUE.com AG
Received on Monday, 16 July 2001 06:42:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:49 GMT