This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 23561 - more tags should be allowed inside <label>
Summary: more tags should be allowed inside <label>
Status: RESOLVED MOVED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: HTML WG Bugzilla archive list
URL: http://www.w3.org/html/wg/drafts/html...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-18 08:41 UTC by Giorgio
Modified: 2016-04-26 22:03 UTC (History)
6 users (show)

See Also:


Attachments

Description Giorgio 2013-10-18 08:41:42 UTC
hello,

i think tags such as <div> or <p> should be allowed inside <label>

i would consider it like <a>, a focusable area that is not necessarily just a span of text

note: browsers didn't modify the parser yet to follow the spec so the following syntax is in fact still allowed and functioning

<label>
     <div>test</div>
     <input type="text">
</label>

(tested all msies 6+, firefox, webkit based browsers)

so, spec could be changed to follow the implementations. what do you think?

I don't have an use case, but i think it's very common the usage of <div>, for example, inside <label>, especially for form styling
Comment 1 alexander surkov 2013-10-18 11:51:02 UTC
people put controls under label to link control and label together (in replace of @for attribute usage), it seems to be a general pattern
Comment 2 Leif Halvard Silli 2013-10-18 13:40:06 UTC
There is one important detail:

Currently the spec says about <label>:

”Contexts in which this element can be used:
    Where phrasing content is expected.”

But if block content is allowed as children of <label>, there would have to be a prohibition on nesting <p> elements:

Contexts in which this element can be used:
    Where phrasing content is expected,
    EXCEPT that when <label> is a child of <p>, then there
    can be no <p> element children of the <label> element.
Comment 3 Giorgio 2013-10-18 17:00:01 UTC
@Leif Halvard Silli

I think it can be considered "transparent content" as spec says about the anchor tag

> Transparent, but there must be no interactive content descendant.

http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#transparent
Comment 4 Leif Halvard Silli 2013-10-18 17:17:31 UTC
(In reply to Giorgio from comment #3)
> @Leif Halvard Silli
> 
> I think it can be considered "transparent content"

That sounds like the way to go.
Comment 5 Travis Leithead [MSFT] 2016-04-26 22:03:23 UTC
HTML5.1 Bugzilla Bug Triage: Moved to Github issue: https://github.com/w3c/html/issues/266

To file additional issues please use the W3C HTML5 Issue tracker: https://github.com/w3c/html/issues/new Thanks!