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

Boris Zbarsky bzbarsky at MIT.EDU
Thu Feb 17 07:23:33 PST 2011

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 

> In fact, the author is attempting to use it as a double label for two
> controls, so semantically it would seem like there is an attempt to
> focus both controls simultaneously. Worse, there's no actual content in
> the label besides controls and whitespace.

We all agree it's crappy markup.

People do this all the time.


More information about the whatwg mailing list