The <select> tag
<select> creates a list for choosing one or several values from a set of option elements.
Syntax
<select name="plan">
<option value="basic">Basic</option>
</select>
Attributes
| multiple | Allows selecting several options at once (usually rendered as a list box rather than a dropdown). |
| size | The number of visible rows without expanding (used together with multiple). |
| required | Makes a selection mandatory before the form can be submitted. |
Example
<select name="plan" required>
<option value="">Choose a plan</option>
<option value="basic">Basic</option>
<option value="pro">Pro</option>
</select>
Notes
- An empty option with value="" as the first item is a common way to make "nothing selected" a valid initial state alongside required.
Accessibility
- Always associate select with a label via for/id, just like input.