html · level 2 · unit 2 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
<select> makes a of options.
When there are many choices, radio buttons fill the page. A drop-down list folds them away. Write <select>, with each choice in its own . The <select> gets the name, the id and the <label>.
Each option has a value, which the server receives, and words between its tags, which visitors see. They can differ: value="lon" can show London.
The first option shows until someone chooses. Add selected to a different option to start on that one instead.
<form>
<label for="city">Nearest shop</label>
<select id="city" name="city">
<option value="lon">London</option>
<option value="lds">Leeds</option>
<option value="gla" selected>Glasgow</option>
</select>
</form> Press show my page to see it here.
Use radio buttons for two to four choices, so people see them all at once, and a drop-down for more.
guess first
Which option will the box show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<label for="film">Film</label>
<select id="film" name="film">
<option value="1">Paddington</option>
<option value="2" selected>Wallace and Gromit</option>
<option value="3">Shaun the Sheep</option>
</select>
your turn
Your turn. Add your own options.
This form asks for a favourite pet. Add two more options of your own on lines 5 and 6, each with a value and words.
Press show my page to see it here.
- the list has three optionsnot checked yet
- your options have valuesnot checked yet
- your options have wordsnot checked yet
fix it
There is a blank choice at the bottom. Can you fix it?
Press show my page to see it here.
- the list has three optionsnot checked yet
- large is the last choicenot checked yet
- The list has a fourth, empty choice. Which tag made it?
- Look at the end of line 5. A closing tag needs a slash.
- Change the last
<option>on line 5 to</option>, then press run.
nailed it
your long lists fold away neatly. :D
<select>holds a drop-down list of<option>choices.- Visitors see the words, and the server receives the
value. selectedpicks which option shows first.
new words in your collection
- drop-down list
- option
This lesson isn’t saved. A free account remembers every lesson you finish.