About Lesson
More Component of HTML form
select
You may use <select>
(with nested option>) elements to build a drop-down menu of items from which a user can pick: By including the chosen attribute in an <option>
element, that option will be shown by default.Â
Â
Additionally, if you want to group options into different categories, you can nest <option> elements in an <optgroup> element:
Definition and Application
- A drop-down list is created with the
<select>
HTML tag. - The
<select>
element is most often used to gather user input in a form.
After the form is submitted, the name property is required to refer to the form data (if you omit the name attribute, no data from the drop-down list will be submitted).
- The
id
element is required to link the drop-down list to a label.
The choices in the drop-down list are defined by the <option> tags in the <select>
element.
Â