Re: proposed change: links inside label elements

One of the advantages is that having an anchor (or anything else) nested
inside the label will not push it to the next line when you set the display
of a label to be 'block'.

A lot of forms have labels above the input fields (with optional micro-text
beside it like 'required', or the example I gave). This is also
best-practice for responsive design, as it's a nice thing to make the full
width of the label clickable for mobile users.

Also there are cases where the input element is nested in the label, like
checkboxes and accompanying text. Anchors should be allowed there as well
(Think about the "Terms & Conditions" checkboxes with a link to the Terms
and Conditions).

Other than that it has no direct 'advantage', like so many other things in
HTML ;-)

I'm not much of a fan for limiting the options an author has when writing
HTML, besides the obvious.

Kind regards,
Reinier Kaper


On 13 January 2014 09:41, Steve Faulkner <faulkner.steve@gmail.com> wrote:

> what advantage does it have over?
>
> <label for="your-domain">Choose a domain name</label> (<a
> href="/link/to/something">How to choose a domain name?</a>)
>
> <input type="text" id="your-domain">
>
> --
>
> Regards
>
> SteveF
> HTML 5.1 <http://www.w3.org/html/wg/drafts/html/master/>
>
>
> On 13 January 2014 14:34, Reinier Kaper <rp.kaper@gmail.com> wrote:
>
>> <label for="your-domain">Choose a domain name (<a
>> href="/link/to/something">How to choose a domain name?</a>)</label>
>> <input type="text" id="your-domain">
>>
>> I guess that's a pretty valid use-case ;-)
>>
>>
>> On 13 January 2014 09:14, Steve Faulkner <faulkner.steve@gmail.com>wrote:
>>
>>> What is idea of making an interactive element under the label as the
>>>> author mistake? Presumably it won't stop the author from doing this?
>>>> Shouldn't it be legalized instead?
>>>
>>>
>>> it has a negative effect on the function of the label and interaction
>>> with the control, it also harmonizes the conformance requirements with that
>>> of other interactive elements.
>>>
>>> do you know of any use cases for including links in label elements?
>>>
>>> --
>>>
>>> Regards
>>>
>>> SteveF
>>> HTML 5.1 <http://www.w3.org/html/wg/drafts/html/master/>
>>>
>>>
>>> On 13 January 2014 14:03, Alexander Surkov <surkov.alexander@gmail.com>wrote:
>>>
>>>> What is idea of making an interactive element under the label as the
>>>> author mistake? Presumably it won't stop the author from doing this?
>>>> Shouldn't it be legalized instead?
>>>> Alexander.
>>>>
>>>>
>>>> On Mon, Jan 13, 2014 at 6:44 AM, Steve Faulkner <
>>>> faulkner.steve@gmail.com> wrote:
>>>>
>>>>> Currently the HTML spec allows links to be inside label elements [1]:
>>>>>
>>>>> example:
>>>>>
>>>>> <label for="test">
>>>>> <a href="http://google.com">google</a></label>
>>>>>
>>>>>
>>>>> <input id="test" type="checkbox">
>>>>>
>>>>> This is problematic because the standard behaviour for a label that is associated with a control is that when
>>>>>
>>>>>
>>>>> clicked/pressed it activates the control (in the example case would check/uncheck the checkbox), but when as in the example
>>>>>
>>>>> the label includes a link, clicking /pressing the label activates the link not the control.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> I propose to change the spec to disallow links in labels (i.e. make it an author conformance error).
>>>>>
>>>>> current text:
>>>>>
>>>>> Content model:Phrasing content, but with no descendant* labelable *elements
>>>>>> [2] unless it is the element's labeled control, and no descendant
>>>>>> label elements.
>>>>>
>>>>>
>>>>> proposed text:
>>>>>
>>>>> Content model:Phrasing content, but with no descendant* interactive *elements
>>>>>> [3] unless it is the element's labeled control, and no descendant
>>>>>> label elements.
>>>>>
>>>>>
>>>>>  [1]
>>>>> http://www.w3.org/html/wg/drafts/html/master/forms.html#the-label-element
>>>>> [2]
>>>>> http://www.w3.org/html/wg/drafts/html/master/forms.html#labelable-elements
>>>>> [3]
>>>>> http://www.w3.org/html/wg/drafts/html/master/dom.html#interactive-content-0
>>>>>
>>>>> feedback welcome!
>>>>> --
>>>>>
>>>>> Regards
>>>>>
>>>>> SteveF
>>>>> HTML 5.1 <http://www.w3.org/html/wg/drafts/html/master/>
>>>>>
>>>>
>>>>
>>>
>>
>

Received on Monday, 13 January 2014 15:19:33 UTC