W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Form controls inside a label but not labelled by it

From: Matthew Raymond <mattraymond@earthlink.net>
Date: Thu, 17 Feb 2011 11:53:07 -0500
Message-ID: <4D5D5273.5000208@earthlink.net>
On 2/17/2011 10:23 AM, Boris Zbarsky wrote:
> On 2/17/11 8:37 AM, Matthew Raymond wrote:
>> <label>
>>    <input type='radio' name='a'>
>>    <textarea></textarea>
>> </label>
>>     The label doesn't specify which control is the one it's labeling.
> But the spec does:
>    If the for attribute is not specified, but the label element has a
>    labelable form-associated element descendant, then the first such
>    descendant in tree order is the label element's labeled control.
> Now the markup here is invalid per the spec (<label>'s content model 
> says "no descendant labelable form-associated elements unless it is the 
> element's labeled control"), but which control is labeled is quite 
> well-defined.

   I just realized that this is irrelevant because of this part of the spec:

    The label element's exact default presentation and behavior, in
    particular what its activation behavior might be, if anything,
    should match the platform's label behavior.

   That means that if clicking a text area wouldn't normally /focus/ an
option button on a particular platform (which, I believe, is all of
them), it shouldn't focus the option button. That means the Mozilla
behavior is definitely invalid.

> We all agree it's crappy markup.
> People do this all the time.

   Never said they didn't. I'm just pointing out that an author has no
reason to believe that a specific behavior will occur based on the
semantics of the markup.
Received on Thursday, 17 February 2011 08:53:07 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC