ISSUE-754: Label elements containing controls

Label elements containing controls

State:
CLOSED
Product:
ARIA 1.1 Name Computation
Raised by:
Cynthia Shelly
Opened on:
2015-11-14
Description:
Label elements containing controls
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.

Might be fine since we don’t expect authors to do this, but good to have a concrete definition of when to use parent <label> elements.
Related Actions Items:
No related actions
Related emails:
No related emails

Related notes:

> 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

Joseph Scheuhammer, 17 Nov 2015, 18:01:31

Per Joseph's comment. The HTML 5.2 spec. states that only the first control within the label (in the absence of the for attribute) receives the name.

Our text in step 2D states:

Otherwise, if the current node's native markup provides an attribute (e.g. title) or element (e.g. HTML label) that defines a text alternative, return that alternative in the form of a flat string as defined by the host language, unless the element is marked as presentational (role="presentation" or role="none").

This leaves the decision off to the host language and it is not an issue for the ARIA spec. if Firefox fails. So, we are covered.

consequently, I am closing this issue as an HTML AAM issue that is decided by that spec.

Richard Schwerdtfeger, 13 Jul 2017, 11:15:36

Display change log ATOM feed


Joanmarie Diggs <jdiggs@igalia.com>, James Nurthen <nurthen@adobe.com>, Chairs, Michael Cooper <cooper@w3.org>, Ruoxi Ran <ran@w3.org>, Staff Contacts
Tracker: documentation, (configuration for this group), originally developed by Dean Jackson, is developed and maintained by the Systems Team <w3t-sys@w3.org>.
$Id: index.php,v 1.326 2018/10/13 17:29:51 vivien Exp $