0
0
HTMLmarkup~20 mins

Label association in HTML - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Label Association Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why use
What is the main benefit of associating a
AIt improves accessibility by linking the label to the input, allowing screen readers to identify the input purpose.
BIt hides the input element from the page.
CIt automatically submits the form when the label is clicked.
DIt changes the color of the input when the label is clicked.
Attempts:
2 left
💡 Hint
Think about how users with screen readers understand form fields.
📝 Syntax
intermediate
1:30remaining
Correct label association syntax
Which HTML snippet correctly associates the label with the input using the for attribute?
HTML
<label for="username">Username:</label>
<input type="text" id="username" name="username">
A
&lt;label&gt;Username:
  &lt;input type="text" id="username" name="username"&gt;
&lt;/label&gt;
B
&lt;label id="username"&gt;Username:&lt;/label&gt;
&lt;input type="text" for="username" name="username"&gt;
C
&lt;label for="user"&gt;Username:&lt;/label&gt;
&lt;input type="text" id="username" name="username"&gt;
D
&lt;label for="username"&gt;Username:&lt;/label&gt;
&lt;input type="text" id="username" name="username"&gt;
Attempts:
2 left
💡 Hint
The label's for attribute must match the input's id exactly.
rendering
advanced
1:30remaining
What happens when clicking a label?
Given this HTML, what happens visually or functionally when the user clicks on the text 'Email Address'?
HTML
<label for="email">Email Address</label>
<input type="email" id="email" name="email">
AThe cursor moves to the email input field, allowing the user to start typing immediately.
BNothing happens because labels are not clickable.
CThe form is submitted automatically.
DThe label text changes color but input is not focused.
Attempts:
2 left
💡 Hint
Think about how labels improve user experience when interacting with forms.
selector
advanced
2:00remaining
CSS selector for styling associated labels
Which CSS selector correctly styles only the
Alabel:has(+ input) { color: blue; }
Blabel[for] { color: blue; }
Clabel[for="email"] { color: blue; }
Dinput + label { color: blue; }
Attempts:
2 left
💡 Hint
Look for a selector that targets labels with a for attribute regardless of input position.
accessibility
expert
2:00remaining
Accessibility issue with missing label association
What is the main accessibility problem with this HTML snippet?
HTML
<label>Email Address</label>
<input type="email" name="email">
AThe label text will not be visible on the page.
BThe input field will not accept any text input.
CScreen readers cannot associate the label text with the input field, making it unclear what the input is for.
DThe form will not submit when pressing Enter.
Attempts:
2 left
💡 Hint
Think about how assistive technologies identify form fields.