[whatwg] LABEL and radio/checkbox onclick

On Mon, 2 Aug 2004, Matthew Raymond wrote:
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>foo</ title><style
> > type="text/css">label {font-family:  sans-serif}</style></head><body><p>Ice
> > cream for everybody!</p><form  action="bar"><label>Flavor:</label> <input
> > id="v" name="flavor"  type="radio" value="v"><label for="v">Vanilla</label>
> > <input id="s"  name="flavor" type="radio" value="s"><label
> > for="s">Strawberry</label>  <input type="submit"
> > value="Order"></form></body></html>
> 
>    From the specification:
> 
>    "The LABEL element is used to specify labels for controls that do
> not have implicit labels"
> 
>    ...AND...
> 
>    "Each LABEL element is associated with exactly one form control."

Neither of those is a conformance requirement, and thus neither can be 
used to argue that the document above is conformant or not. Both are 
either statements of intent or general truisms. The first seems to be a 
statement of intent ("this is what we wanted it to do"). The second seems 
like it was supposed to be a truism. It raises a question, though, which 
is "how do you determine which form control is associated with the 
"Flavor:" label above?".


>    I'm not sure what you mean by the terms "valid" and "conformant".

"Valid" means "syntacticaly correct according to the DTD", which is a 
subset of "conformant".

"Conformant" means "conforming to the spec's conformance requirements".


>    On the other hand, you can easily make <label> behave like it does in 
> most operating systems by simply using text instead of the <label> 
> element. Why try to eliminate a feature of HTML when the web authors are 
> fully capable of dealing with and problems by making trivial changes to 
> markup?

I really don't understand why you _want_ labels to do the wrong thing.

Using text instead of <label> elements is semantically poor (at best) or 
even plain wrong (at worst) and prevents static analysis user agents like 
robots and screen readers from giving their users an optimal experience. 
(That's another way of saying "it breaks accessibility".)

That clicking a label element transfers focus is not a feature of HTML, 
it's a misfeature and almost certainly another example of vague and 
misleading comments in the spec, rather than actual intent from the 
authors of the HTML spec.

One of the best things about strongly semantic markup like HTML's is that 
it can automatically adapt to the environment, rendering appropriately 
whatever the operating system or platform. On some platforms, buttons can 
take focus; on others, they can't. On some platforms, labels can be 
activated and cause focus to be transfered (or even more, e.g. a checkbox 
to get checked); on others, they can't. Some platforms have labels that 
apply to some elements; others, other elements.

The beauty of HTML and semantic markup is that the _same_ source document 
can result in correct, platform-convention-following interfaces whatever 
the actual platform is, without the author having to even know the 
platform exists, let alone what conventions it has.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Sunday, 22 August 2004 04:51:11 UTC