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 24279 - should links be allowed inside labels?
Summary: should links be allowed inside labels?
Status: RESOLVED NEEDSINFO
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on: 24278
Blocks:
  Show dependency treegraph
 
Reported: 2014-01-13 10:32 UTC by steve faulkner
Modified: 2014-01-14 19:10 UTC (History)
5 users (show)

See Also:


Attachments

Description steve faulkner 2014-01-13 10:32:50 UTC
+++ This bug was initially created as a clone of Bug #24278 +++

"Phrasing content, but with no descendant labelable elements unless it is the element's labeled control, and no descendant label elements."
http://www.w3.org/html/wg/drafts/html/master/forms.html#the-label-element
example:
<label for="test"><a href="http://google.com">google</a></label><input id="test" type="checkbox">  

or if you prefer a real world example:

<input id="boston_region" type="checkbox" name="locations" value="boston_region">

<label for="boston_region">
	<a id="x:219752177.6:mkr:dtnContent" 
	class="igdt_Node igdt_NodeParent"  href="#" 
	title="BOR - Boston Region" 
	mkr="dtnContent">BOR - Boston Region</a>
</label>


this breaks the expected behaviour of a label activating the control in IE/chrome/firefox. 

suggest changing to "no descendant interactive elements"
Comment 1 Ian 'Hixie' Hickson 2014-01-13 17:18:18 UTC
At least in Chrome, the link still works:
   http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2736

I still need to test other browsers though.
Comment 2 steve faulkner 2014-01-13 17:26:52 UTC
(In reply to Ian 'Hixie' Hickson from comment #1)
> At least in Chrome, the link still works:
>    http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2736
> 
> I still need to test other browsers though.

this breaks the expected behaviour of a label activating the control in IE/chrome/firefox. 

further discussion/checking  has lead me to think that only when the label text is wholly contained within the link text that it presents a problem
http://lists.w3.org/Archives/Public/public-html/2014Jan/0063.html
Comment 3 Ian 'Hixie' Hickson 2014-01-13 23:38:23 UTC
Tested on Firefox too, and Firefox is also consistent with the spec.

I'm not understanding what the problem is here. Can you elaborate?

Obviously if the label only contains a link and a control, there's no text to click on that acts as a label, but where's the problem? Or are you saying that if someone used a label, they probably didn't mean to not have any non-link text? I the latter, then I think it's good to allow authors to use the <label> element even when it doesn't do anything useful, because it allows for consistent markup in the case of most labels not being a link but some being a link. For example, this very bug page does something much like that.
Comment 4 github bugzilla bot 2014-01-14 10:50:03 UTC
Commit pushed to master at https://github.com/w3c/html

https://github.com/w3c/html/commit/11c025f70bf7364e37cec508592c99916f92c3c8
added advice about effect of linked labels

see bug 24279
Comment 5 steve faulkner 2014-01-14 10:57:52 UTC
(In reply to github bugzilla bot from comment #4)
> Commit pushed to master at https://github.com/w3c/html
> 
> https://github.com/w3c/html/commit/11c025f70bf7364e37cec508592c99916f92c3c8
> added advice about effect of linked labels
> 
> see bug 24279

whoops sorry added to wrong bug
Comment 6 Ian 'Hixie' Hickson 2014-01-14 19:10:52 UTC
Please reopen when responding to comment 3, thanks.