Drop-down List
When there are more options to choose from, a drop-down list saves space. We create it with the select element, and each option in it with an option element.
Each option has a value attribute, which is sent with the form, and its content is the text the user sees. The name and id attributes, and the label, belong to the select element, just like with an input. Unlike input, select has a closing tag, because the options go inside it.
<label for="input-pizza">Pizza</label>
<select name="pizza" id="input-pizza">
<option value="margherita">Margherita</option>
<option value="salami">Salami</option>
<option value="hawaii">Hawaii</option>
</select>This code is displayed like this:
When the user chooses Salami, the form sends pizza=salami.
In our form, the user will choose the course they want to sign up for.
Instructions
In the empty div, create a select element with the attribute name with the value course and the attribute id with the value input-course.
Inside the select, create three option elements with the contents HTML, CSS and JavaScript and the values html, css and javascript.
Before the select, create a label with the content Course and the attribute for with the value input-course.
Start programming for free
7/11