- From: David Dorward <david@dorward.me.uk>
- Date: Tue, 28 Oct 2003 15:21:18 +0000
- To: "Emlyn Addison" <emlyn@neinetwork.com>
- Cc: <www-html@w3.org>
On Tuesday, Oct 28, 2003, at 15:02 Europe/London, Emlyn Addison wrote: > I discovered an unusual conflict in the <label> requirements for HTML > forms. It seems that the "id" attribute in a form element must contain > the same name as the "for" attribute in the <label> tag in order for > these to be related. It is probably better to think of that the other way around... The id attribute of an element just gives it a unique identifier which can be referenced by a number of technologies, including the for attribute of labels, the CSS id selector, and the JavaScript/DOM document.getElementById(). It isn't true anyway, <label>Foo <input></label> relates the label to the input as well... although browser support isn't as good. > But if that form element already had a CSS "id" attribute associated > with it (for stylistic reasons) There is no such thing as a CSS id attribute. CSS has an id selector which lets you match a style to an element based on its unique identifier. > , then the <label> tag cannot be associated with it. For example: > > <label for="fname">First name:</label> <input type="text" > name="firstname" id="redBorder" value=""> <label for="redBorder"> ... but that's a very bad id for an element. "This element is the one and only thing called redBorder"?! You are aware that you can't reuse an id in a document, even if certain browsers[1] let you get away with it? It sounds like you: a) Need to be using classes and b) Need to rethink your names I suspect that something along the lines of class="required" is in order. [1] Insert unprintable comments about a Redmond based company -- David Dorward http://dorward.me.uk/
Received on Tuesday, 28 October 2003 10:26:34 UTC