You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/template-require-input-label.md
+79-20Lines changed: 79 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,48 +2,101 @@
2
2
3
3
<!-- end auto-generated rule header -->
4
4
5
-
Require form input elements to have an associated label for accessibility.
5
+
Users with assistive technology need user-input form elements to have
6
+
associated labels.
6
7
7
-
## Rule Details
8
+
The rule applies to the following HTML tags:
8
9
9
-
This rule enforces that input, textarea, and select elements have a way to be labeled, either through an `id` attribute (which can be referenced by a `<label for="...">`) or through `aria-label` or `aria-labelledby` attributes.
10
+
-`<input>`
11
+
-`<textarea>`
12
+
-`<select>`
13
+
14
+
The rule also applies to the following ember components:
15
+
16
+
-`<Textarea />`
17
+
-`<Input />`
18
+
-`{{textarea}}`
19
+
-`{{input}}`
20
+
21
+
The label is **essential** for users. Leaving it out will cause **three**
22
+
different WCAG criteria to fail:
23
+
24
+
-[1.3.1, Info and Relationships](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships.html)
25
+
-[3.3.2, Labels or Instructions](https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions.html)
-[#68: Failure of Success Criterion 4.1.2 due to a user interface control not having a programmatically determined name](https://www.w3.org/WAI/WCAG21/Techniques/failures/F68)
31
+
32
+
This rule checks to see if the input is contained by a label element. If it is
33
+
not, it checks to see if the input has any of these three attributes: `id`,
34
+
`aria-label`, or `aria-labelledby`. While the `id` element on the input is not
35
+
a concrete indicator of the presence of an associated `<label>` element with a
36
+
`for` attribute, it is a good indicator that one likely exists.
37
+
38
+
This rule does not allow an input to use a `title` attribute for a valid label.
39
+
This is because implementation by browsers is unreliable and incomplete.
40
+
41
+
This rule is unable to determine if a valid label is present if `...attributes`
42
+
is used, and must allow it to pass. However, developers are encouraged to write
43
+
tests to ensure that a valid label is present for each input element present.
-[Using label elements to associate text labels and form controls](https://www.w3.org/WAI/WCAG21/Techniques/html/H44.html)
123
+
-[Using aria-labelledby to provide a name for user interface controls](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA16)
124
+
-[Using aria-label to provide an invisible label where a visible label cannot be used](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA14.html)
125
+
-[Failure due to a user interface control not having a programmatically determined name](https://www.w3.org/WAI/WCAG21/Techniques/failures/F68)
126
+
-[Failure due to visually formatting a set of phone number fields but not including a text label](https://www.w3.org/WAI/WCAG21/Techniques/failures/F82)
0 commit comments