Skip to content

Commit 3fe392b

Browse files
fix(curriculum): replace uncovered quiz questions and add interactive example (freeCodeCamp#63780)
1 parent f828893 commit 3fe392b

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

curriculum/challenges/english/blocks/lecture-accessible-tables-forms/672a53ae8f1ad28c8a1ed0f0.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ challengeType: 19
55
dashedName: why-is-it-important-for-inputs-to-have-an-associated-label
66
---
77

8-
# --description--
8+
# --interactive--
99

1010
Labels on input fields might seem like small details, but they play a crucial role in making forms easier for everyone to use.
1111

@@ -17,13 +17,17 @@ Screen readers often rely on labels to describe the purpose of input fields. In
1717

1818
Here's how to associate a `label` with an `input`:
1919

20+
:::interactive_editor
21+
2022
```html
2123
<form>
2224
<label for="name">Your Name</label>
2325
<input type="text" id="name" />
2426
</form>
2527
```
2628

29+
:::
30+
2731
In this example, the `for` attribute of the `label` element is associated with the `id` of the `input` element. This connection allows screen readers to announce the `label` when the `input` is in a focused state, allowing screen reader users to understand the purpose of the `input`.
2832

2933
Associating labels with all input fields also benefits SEO. With proper labels, search engines will understand the page content better, leading to a positive impact on the page search rankings.
@@ -70,71 +74,71 @@ Think about how screen readers provide information to users.
7074

7175
## --text--
7276

73-
How do labels associated with input fields improve keyboard navigation?
77+
What is the correct way to programmatically associate a label with an input in HTML?
7478

7579
## --answers--
7680

77-
They enhance the visual appearance of input fields.
81+
Give both elements the same `name` attribute.
7882

7983
### --feedback--
8084

81-
Focus on how users move through a form using only the keyboard.
85+
Review the example in the lesson showing how `for` and `id` are used together.
8286

8387
---
8488

85-
They allow users to tab through input fields without getting lost.
89+
Set the label's `for` attribute to match the input's `id`.
8690

8791
---
8892

89-
They reduce the need for keyboard shortcuts.
93+
Place the `<label>` immediately after the `<input>` element in the DOM.
9094

9195
### --feedback--
9296

93-
Focus on how users move through a form using only the keyboard.
97+
Order alone does not create an association that screen readers can use.
9498

9599
---
96100

97-
They let input fields accept special characters.
101+
Use the input's `placeholder` text instead of a label.
98102

99103
### --feedback--
100104

101-
Focus on how users move through a form using only the keyboard.
105+
Placeholders are not a replacement for accessible, programmatically associated labels.
102106

103107
## --video-solution--
104108

105109
2
106110

107111
## --text--
108112

109-
How do labels associated with input fields help in identifying errors?
113+
Besides accessibility, what other benefit of associating labels with inputs is mentioned in the lesson?
110114

111115
## --answers--
112116

113-
They allow input fields to accept longer text.
117+
It makes the page load significantly faster.
114118

115119
### --feedback--
116120

117-
Think about how error messages are communicated to users by screen readers.
121+
Performance is not the benefit discussed in this lesson.
118122

119123
---
120124

121-
They help screen readers announce the label along with the error message.
125+
It can help search engines better understand the page content.
122126

123127
---
124128

125-
They prevent users from submitting forms.
129+
It allows inputs to accept multiple data types automatically.
126130

127131
### --feedback--
128132

129-
Think about how error messages are communicated to users by screen readers.
133+
Data types are determined by the input's `type` attribute, not labels.
130134

131135
---
132136

133-
They make input fields more colorful.
137+
It automatically translates labels for international users.
134138

135139
### --feedback--
136140

137-
Think about how error messages are communicated to users by screen readers.
141+
Internationalization is outside the scope of what labels provide.
138142

139143
## --video-solution--
140144

0 commit comments

Comments
 (0)