[whatwg] Proposal: Allow block content inside label element

Ian Hickson ian at hixie.ch
Tue Oct 28 17:08:15 PDT 2008


On Mon, 7 May 2007, Brad Fults wrote:
>
> Currently, as far as I can tell, in HTML 4 and HTML 5, 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.
> 
> Could we remedy this by allowing block content inside of a label 
> element?

<textarea> is allowed in <label> in HTML5. (And HTML4, too, actually.)


On Tue, 8 May 2007, Kristof Zelechovski wrote:
>
> I have a weak feeling against this proposition.  Not that I think it would
> harm very much, it just seems not very appropriate.
> From the behavioral point of view: The purpose of a LABEL control is to
> redirect focus on click.  It does not make much sense with a TEXTAREA
> control that is usually big enough to click upon.  
> From a semantic point of view: the TEXTAREA control is special because it
> does not make sense to ask whether the content of the TEXTAREA is or even
> contains some fixed text because the user may express the same meaning with
> different words; its content may be stored but you have to use advanced text
> analysis tools (such as a human reader) to process it if you need to.  You
> can use a label to define what you expect the user to enter into the
> control; the TEXTAREA control is so special that it seems obvious that it
> needs a caption or some introductory explanation, not a label (except for
> the labels "Your message" and "Your text", which are possible but not very
> informative indeed.)

I disagree, it seems quite reasonable to me. It's common in OS UIs, why 
not on the Web?


On Tue, 8 May 2007, Benjamin Hawkes-Lewis wrote:
> 
> It would probably help if we could associate short labels and longer 
> descriptions with form fields. It would certainly help if we could do so 
> with fieldsets:
> 
> http://www.rnib.org.uk/wacblog/general-accessibility/too-much-accessibility-fieldset-legends/

I don't really follow. The blog post has good advice, but doesn't seem to 
point to a problem in the spec.


On Wed, 9 May 2007, Køi¹tof ®elechovski wrote:
>
> The restriction on LABEL behavior is not a clarification, it is a change.
> The browser vendor has to choose whether it is compliant with version 4 or
> 5.  Therefore the current behavior can hardly be called a bug.  Note that
> this change is not reported on the Wiki
> <http://wiki.whatwg.org/wiki/Changes_from_HTML4#Changed_Elements>; I did not
> update the content because I strongly oppose this idea.  It seems it has
> strong support
> <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2004-July/thread.html#1
> 366> - where Mr. Raymond's opinion unfortunately sank - but there is a
> possibility to overthrow it by making it void on a legal basis:
> The Microsoft Windows environment does not provide a native LABEL control.*
> It there was one, the restriction of version 5 would perhaps apply.  But you
> cannot tell how the native control behaves when it does not exist.  You can
> assume it would redirect the focus to the input control if it existed, and
> introduce the feature to the browser upon that assumption. [...]

Windows clearly does have the equivalent of a label control, even if it 
doesn't expose it as such. The behavior in HTML5, whether you call it a 
change or a clarification, is the right thing for us to require.


On Fri, 11 May 2007, Køi¹tof ®elechovski wrote:
>
> The speculative wording of HTML5 is actually less accurate because it 
> refers to a platform control which need not exist at all.  The 
> imperative wording of HTML4 is both clearer and more accurate.

The text in HTML5 now says "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." which seems fine to 
me.


On Tue, 8 May 2007, Martin Atkins wrote:
> 
> 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.

Have you tried just display:block on the textarea instead?

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


More information about the whatwg mailing list