WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: using "label for=" on things other than inputs


From: Jonathan Avila
Date: Feb 19, 2016 6:42PM

Ø FYI the list of labelable elements in HTML5 includes - button <http://www.w3.org/TR/html5/forms.html#the-button-element>;

WCAG Technique H44<https://www.w3.org/TR/2015/NOTE-WCAG20-TECHS-20150226/H44> states:

Note 2: The label element is not used for the following because labels for these elements are provided via the value attribute (for Submit and Reset buttons), the alt attribute (for image buttons), or element content itself (button).

'Submit and Reset buttons ( input type="submit" or input type="reset")

'Image buttons ( input type="image")

'Hidden input fields ( input type="hidden")

'Script buttons (button elements or <input type="button">)

HTML Accessibility API Mappings 1.0<https://www.w3.org/TR/html-aam-1.0/#button-element> also indicates the following which does not seem to include the label element:

5.4 button Element
5.4.1 button Element Accessible Name Calculation

1. If the button element has an aria-label<http://www.w3.org/TR/wai-aria-1.1/#aria-label>; or an aria-labelledby<http://www.w3.org/TR/wai-aria-1.1/#aria-labelledby>; attribute the accessible name<https://www.w3.org/TR/html-aam-1.0/#dfn-accessible-name> is to be calculated using the algorithm defined in Accessible Name and Description: Computation and API Mappings 1.1<http://rawgit.com/w3c/aria/master/accname-aam/accname-aam.html>;.
2. Otherwise use the button element subtree
3. Otherwise use title attribute
4. If none of the above yield a usable text string there is no accessible name<https://www.w3.org/TR/html-aam-1.0/#dfn-accessible-name>


-----Original Message-----
From: WebAIM-Forum [mailto: <EMAIL REMOVED> ] On Behalf Of Steve Faulkner
Sent: Friday, February 19, 2016 7:12 PM
To: WebAIM Discussion List
Subject: Re: [WebAIM] using "label for=" on things other than inputs

FYI the list of labelable elements in HTML5 includes

- button <http://www.w3.org/TR/html5/forms.html#the-button-element>;

- input <http://www.w3.org/TR/html5/forms.html#the-input-element>; (if the type <http://www.w3.org/TR/html5/forms.html#attr-input-type>; attribute is

*not* in the hidden

<http://www.w3.org/TR/html5/forms.html#hidden-state-(type=hidden)> state)

- keygen <http://www.w3.org/TR/html5/forms.html#the-keygen-element>;

- meter <http://www.w3.org/TR/html5/forms.html#the-meter-element>;

- output <http://www.w3.org/TR/html5/forms.html#the-output-element>;

- progress <http://www.w3.org/TR/html5/forms.html#the-progress-element>;

- select <http://www.w3.org/TR/html5/forms.html#the-select-element>;

- textarea <http://www.w3.org/TR/html5/forms.html#the-textarea-element>;


On Friday, 19 February 2016, Detlev Fischer < <EMAIL REMOVED> <mailto: <EMAIL REMOVED> >>


> Short question: When checking forms for a11y, I often see that 'label'

> with an explicit association via the 'for' attribute is used on things

> other than input elements. For example, on a button that will add a

> user via a pseudo popup dialog, or on text that is read-only because a

> user may not have permission to input data at this point.

> The label does not activate the button so using it does not extend the

> click area for mouse users as is the case with checkboxes or radio buttons.

> The proper label of the button is of course given via the value of the

> button (or link text of links made to look like buttons).


> So the question I have come up with is whether

> (A) I should dissuade developers from using label on content that

> is not suitable

> as a labeled control even though the use may be harmless

> (B) Whether this unintended use of label for="" would violate 4.1.2

> or is actually harmless


> One reason for using label for developers is of course that they can

> apply the same styling to label elements regardless of whether they

> are labels of inputs or labels of other stuff that is not an input

> (read-only content, buttons etc.). There can also be different

> variants of a form where depending on the rights of the user an

> element may be a proper input or read-only content, so it is probably

> unreasonable to expect developers to create different variants of the

> same form mark-up depending on permission rights.



> --

> Detlev Fischer

> testkreis - das Accessibility-Team von feld.wald.wiese c/o

> feld.wald.wiese Thedestraße 2

> 22767 Hamburg


> Mobil +49 (0)157 57 57 57 45

> Fax +49 (0)40 439 10 68-5


> http://www.testkreis.de

> Beratung, Tests und Schulungen für barrierefreie Websites






> > archives at http://webaim.org/discussion/archives

> >





Current Standards Work @W3C