[whatwg] Proposal: Allow block content inside label element

Martin Atkins mart at degeneration.co.uk
Tue May 8 12:10:37 PDT 2007


Brad Fults wrote:
> Currently, as far as I can tell, in HTML 4 [1] and HTML 5 [2], the
> label element is defined as having inline content. When using the
> implicit form control association pattern described in the HTML 4 spec
> (e.g. a form control inside of the label element instead of or in
> addition to using the |for| attribute), this becomes a problem.
> 
> Specifically, if one tries to place a textarea element inside of a
> label element, modern browsers will insert the textarea as a later
> sibling to the label in the DOM instead of as a child. This seems to
> be due to the fact that the textarea is a block element and that label
> can't contain it according to the spec.
> 

Some software that I'm responsible for frequently wraps <label> elements 
around <div> elements, purely because current versions of IE will not 
apply display:inline-block to inline elements. While I guess that is 
using a deviation from the HTML spec in order to compensate for a 
deviation from the CSS spec[1], it's still something I'm not going to be 
able to stop doing without a large amount of work.

For this reason, I certainly wouldn't mind label allowing block-level 
children. Both Opera 9 and IE6 (the only browsers I have handy to test 
right now) already support DIV as a child of LABEL correctly, per 
Hixie's DOM viewer.[2]



[1] A part of the CSS spec that Microsoft pioneered, but still...
[2] 
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E%0D%0A%3Clabel%3E%3Cdiv%3Edsfgdsfgsdfgsdf%3C/div%3E%3C/label%3E



More information about the whatwg mailing list