HTML <select> Tag
<select name="Food">
<option value ="apples">Apples</option>
<option value ="bananas">Bananas</option>
<option value ="oranges">Oranges</option>
</select>
The above example demonstrates usage of the <select>
element.
The <select>
element represents a control for selecting amongst a set of options. This is typically rendered as a drop down menu containing a list of options.
In a <select>
list, each option is represented by an <option>
element. If there are many items, they can (optionally) be grouped using the <optgroup>
element.
Attributes
The <select>
element accepts the following attributes (as well as the global HTML attributes):
autofocus
- Automatically focus the form control when the page is loaded
disabled
- Whether the form control is disabled
form
- Associates the control with a
<form>
multiple
- Whether to allow multiple values
name
- Name of form control to use for form submission (and in the
form.elements
API) required
- Whether the control is required for form submission
size
- Size of the control