Bug #100965
closedFe-Login Accessibility - Forms must offer for and id
100%
Description
According to the A11y Code Sprint Berlin, all form labels must offer the for property and all inputs must have an id
Adjust the fe-login template to offer these by default, just like indexed search is already doing.
See https://github.com/benjaminkott/bootstrap_package/issues/1325
Updated by Gerrit Code Review over 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79194
Updated by Gerrit Code Review over 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79194
Updated by Gerrit Code Review over 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79205
Updated by Lina Wolf over 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8eb265de9ac92c4069ee8eec7088b1a88d61f513.
Updated by Gerrit Code Review over 1 year ago
- Status changed from Resolved to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/79208
Updated by Lina Wolf over 1 year ago
- Status changed from Under Review to Resolved
Updated by Ayke Halder 3 months ago · Edited
See https://www.w3.org/WAI/WCAG22/Techniques/failures/F68.html#tests
Procedure¶
For all
input
,textarea
, andselect
elements in the Web page (except inputs of typehidden
,submit
,reset
, orbutton
:1. Check that each element has a programmatically determined name using one of the following ways:
1.1. […]
1.2. […]
1.3. the text label is contained in alabel
element that is correctly associated to the respectiveinput
element via the label'sfor
attribute (theid
given as value in thefor
attribute matches theid
of the input element).
1.4. the control is contained within alabel
element that also contains the label text.
1.5. […]
1.6. […]
So I'd say the following code should be 'QA successful' as of '1.4.' above:
<label>
Username
<input type="text" …>
</label>
We really get into trouble if we need to set unique id
attributes everywhere. As soon as a form is used twice on the same page, the id
isn't unique anymore.
The result of a non-unique id
is a wrong label-association. A wrong label-association is far worse than not providing the id
and for
attributes to 'improve' an already working label-to-input association.
Also see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
To explicitly associate a
<label>
element with an<input>
element, you first need to add theid
attribute to the<input>
element. Next, you add thefor
attribute to the<label>
element, where the value offor
is the same as theid
in the<input>
element.Alternatively, you can nest the
<input>
directly inside the<label>
, in which case thefor
andid
attributes are not needed because the association is implicit:
<label>
Do you like peas?
<input type="checkbox" name="peas" />
</label>
And see (german): https://bitvtest.de/pruefschritt/bitv-20-web/bitv-20-web-9-1-3-1h-beschriftung-von-formularelementen-programmatisch-ermittelbar
Was wird geprüft?¶
Beschriftungen sollen über Markup mit den Formularelementen, die sie beschriften, verknüpft sein.
Bei
label
-Elementen geschieht das über dasfor
-Attribut oder den Einschluss des beschrifteten Formularelements in daslabel
-Element. […]
Updated by Albrecht Köhnlein 3 months ago · Edited
(reply to Akye, who suggested to remove the for and id attributes)
Nesting the tags and skipping for/id attributes is supported by all modern browsers, but not by all assistive technology. Not adding the for/id attributes is not perfect for voice control:
See https://www.tpgi.com/should-form-labels-be-wrapped-or-separate/
This is not a blocker, because users have multiple ways to reach and activate controls. (...)
But the problem is easily fixable anyway, simply by adding explicit association.
This article recommends to use for/id attributes even for nested label/input tags.