Tie a label to a text input.
Acceptance criteria
- 1.Tie a label to a text input.
HTML Tutorial · HTML Tags
These 10 tasks go with the HTML <label> Tag chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “The tag is used to define a label for an HTML form control like , , or . Clicking the label automatically focuses the associated form control , improving usability and accessibility . Associating labels with controls helps screen readers and improves user experience.” .
1.Label a fieldexercise · easy · 10 min
Tie a label to a text input.
Passes when: Tie a label to a text input.
2.Wrap the inputexercise · easy · 10 min · practice plan
Put the input inside the label instead of using for.
Passes when: Put the input inside the label instead of using for.
3.Label a checkboxexercise · easy · 10 min · practice plan
Tie a label to a checkbox.
Passes when: Tie a label to a checkbox.
4.Two labelled fieldsexercise · easy · 10 min · practice plan
Label both a name and an email field.
Passes when: Label both a name and an email field.
5.A labelled form rowexercise · medium · 10 min · practice plan
Build a form with a label, an input and a submit button.
Passes when: Build a form with a label, an input and a submit button.
6.Fix the label pointing at the wrong idbug fix · easy · 8 min
The for value must match the input's id.
Passes when: The for value must match the input's id.
7.Fix the plain text used as a labelbug fix · easy · 8 min · practice plan
A caption for a field is a label element.
Passes when: A caption for a field is a label element.
8.Fix the unlabelled checkboxbug fix · easy · 8 min · practice plan
A checkbox needs a label to be clickable and readable.
Passes when: A checkbox needs a label to be clickable and readable.
9.Fix the missing second labelbug fix · easy · 8 min · practice plan
Only one of the two fields is labelled.
Passes when: Only one of the two fields is labelled.
10.Fix the label outside the formbug fix · easy · 8 min · practice plan
The label belongs with the field it names.
Passes when: The label belongs with the field it names.
Between them these tasks cover Labels, for and id and Click targets.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.