Add a datalist with two options and link it to an input.
Acceptance criteria
- 1.Add a datalist with two options and link it to an input.
HTML Tutorial · HTML Tags
These 10 tasks go with the HTML <datalist> 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 provide a list of predefined options for an element. It allows users to type a value or select from a list , offering a flexible and user-friendly input experience. The element must be linked to an using the list attribute.” .
1.Offer suggestionsexercise · easy · 10 min
Add a datalist with two options and link it to an input.
Passes when: Add a datalist with two options and link it to an input.
2.Give the list an idexercise · easy · 10 min · practice plan
The datalist needs an id for the input to reference.
Passes when: The datalist needs an id for the input to reference.
3.Link the inputexercise · easy · 10 min · practice plan
Point an input at an existing datalist.
Passes when: Point an input at an existing datalist.
4.Three suggestionsexercise · easy · 10 min · practice plan
Offer three suggested values.
Passes when: Offer three suggested values.
5.A suggested city fieldexercise · medium · 10 min · practice plan
Build a labelled input with three suggestions.
Passes when: Build a labelled input with three suggestions.
6.Fix the input not linked to the listbug fix · easy · 8 min
The input needs a list attribute.
Passes when: The input needs a list attribute.
7.Fix the datalist with no idbug fix · easy · 8 min · practice plan
Without an id nothing can reference it.
Passes when: Without an id nothing can reference it.
8.Fix the list pointing at the wrong idbug fix · easy · 8 min · practice plan
The list value must match the datalist's id.
Passes when: The list value must match the datalist's id.
9.Fix the missing third suggestionbug fix · easy · 8 min · practice plan
Tokyo was left out.
Passes when: Tokyo was left out.
10.Fix the select used where free text is neededbug fix · easy · 8 min · practice plan
A datalist suggests without restricting.
Passes when: A datalist suggests without restricting.
Between them these tasks cover Suggestions, list attribute and Free text with hints.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.