Challenge - 5 Problems
Label Association Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why use
What is the main benefit of associating a
Attempts:
2 left
💡 Hint
Think about how users with screen readers understand form fields.
✗ Incorrect
Associating a label with an input using the for attribute helps screen readers announce the label text when the input is focused, improving accessibility.
📝 Syntax
intermediate1: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">
Attempts:
2 left
💡 Hint
The label's for attribute must match the input's id exactly.
✗ Incorrect
The label's for attribute should match the input's id to create a proper association. Option D nests input inside label which is valid but does not use for attribute.
❓ rendering
advanced1: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">
Attempts:
2 left
💡 Hint
Think about how labels improve user experience when interacting with forms.
✗ Incorrect
Clicking a label linked with for attribute focuses the associated input, making it easier to fill forms.
❓ selector
advanced2:00remaining
CSS selector for styling associated labels
Which CSS selector correctly styles only the
Attempts:
2 left
💡 Hint
Look for a selector that targets labels with a for attribute regardless of input position.
✗ Incorrect
label[for] selects all label elements that have a for attribute, which means they are associated with an input by id. Option B targets only one specific id, B targets labels immediately after inputs, A is invalid because :has() cannot select previous siblings.
❓ accessibility
expert2: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">
Attempts:
2 left
💡 Hint
Think about how assistive technologies identify form fields.
✗ Incorrect
Without a for attribute on the label or nesting the input inside the label, screen readers cannot link the label text to the input, reducing accessibility.