WebAIM - Web Accessibility In Mind

E-mail List Archives

using "label for=" on things other than inputs

for

From: Detlev Fischer
Date: Feb 18, 2016 11:55PM


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