HTML forms - Drop-down menu
We can also add drop-down menus to our HTML forms.
We can use the select element to implement these drop-down menus. Input choices are in 鈥渙ption鈥 elements as shown in the example below.
Code below:
<form>
Select city:
<select name="city">
<option value="Aberdeen">Aberdeen</option>
<option value="Dundee">Dundee</option>
<option value="Edinburgh">Edinburgh</option>
<option value="Glasgow">Glasgow</option>
<option value="Inverness">Inverness</option>
<option value="Perth">Perth</option>
<option value="Stirling">Stirling</option>
</select>
</form>
Each city has been set in the option value part of the element. The name=鈥漜ity鈥 and value attributes are not required at Higher, but they are useful to state.