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 29283 - Label elements containing controls
Summary: Label elements containing controls
Status: RESOLVED INVALID
Alias: None
Product: ARIA
Classification: Unclassified
Component: HTML AAM (show other bugs)
Version: 1.0
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: steve faulkner
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-14 02:18 UTC by Cynthia Shelly
Modified: 2018-05-03 21:19 UTC (History)
3 users (show)

See Also:


Attachments

Description Cynthia Shelly 2015-11-14 02:18:02 UTC
see also: https://www.w3.org/WAI/PF/Group/track/issues/754

Do we use label elements that contain controls? Maybe only if the control is the first child of the label?

 <label>I have a <input type=”checkbox” />checkbox and a <button>button</button> here</label>

 I don’t think the label containing these controls makes sense to be the name for either, and definitely not both.

Please add a concrete definition of when to use parent <label> elements.
Comment 1 Joseph Scheuhammer 2015-11-17 18:00:31 UTC
> Do we use label elements that contain controls? Maybe only if the control is
> the first child of the label?

Your intuition matches the HTML5.1 nightly [1].  If a <label> element has no @for attribute, then the "... the first such descendant in tree order is the label element's labeled control." One of the spec's examples is:

<label><input type=checkbox name=lost> Lost</label>

The accessible name of the checkbox accessible for the above is "Lost".

Based on that, in your example, the <label> applies only to the checkbox <input>.  Repeating your example here:

<label>I have a <input type=”checkbox” />checkbox and a <button>button</button> here</label>

The accessible name for the checkbox accessible is "I have a checkbox and a button here".

Since the <label> does not apply to the (enclosed) <button>, then its accessible name should be "button".

FWIW, FF produces "I have a checkbox and a button here" as the accessible name for *both* the checkbox and the button.


[1] http://www.w3.org/html/wg/drafts/html/master/single-page.html#the-label-element
Comment 2 alexander surkov 2015-11-18 21:26:24 UTC
btw, I filed a bug for firefox issue https://bugzilla.mozilla.org/show_bug.cgi?id=1226000
Comment 3 alexander surkov 2015-11-19 16:54:24 UTC
I think the a11y spec should refer to the HTML spec, saying that labelled control takes its accessible name from its label element [1], and related with it by certain accessible relations.

[1] http://www.w3.org/html/wg/drafts/html/master/single-page.html#labeled-control
Comment 4 James Nurthen 2018-05-03 21:19:24 UTC
HTML AAM is no longer an ARIA Deliverable. If you wish to pursue this issue please file at https://github.com/w3c/html-aam/issues