Re: On id and name attributes

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 UTC