The HTML <select> element creates a dropdown (or list box) for choosing from predefined options. Use it for structured choices like countries, categories, or preferences. It works together with <option> for individual items and <optgroup> for grouping related options.
By default, a <select> is single-select. Add the multiple attribute to allow multi-selection, and use size to control how many items are visible without scrolling.
multiple for multi-select behavior.size > 1).<option> defines each selectable item.<optgroup label="..."> groups related options visually and semantically.value, selected, and disabled state.name="fruits[]".<label> via its for attribute.
<!-- Single-select with a placeholder option -->
<form action="#" onsubmit="return false;">
<label for="country">Country</label>
<select id="country" name="country" required aria-describedby="countryHelp">
<option value="" disabled selected hidden>Select a country</option>
<optgroup label="Europe">
<option value="es">Spain</option>
<option value="de">Germany</option>
</optgroup>
<optgroup label="Asia">
<option value="in">India</option>
<option value="jp">Japan</option>
</optgroup>
</select>
<small id="countryHelp" class="help">Choose exactly one.</small>
</form>
<!-- Multi-select list box (note the name as an array for many backends) -->
<form action="#" onsubmit="return false;">
<label for="fruits">Favorite fruits</label>
<select id="fruits" name="fruits[]" multiple size="6" required aria-describedby="fruitsHelp">
<optgroup label="Citrus">
<option value="orange">Orange</option>
<option value="lemon">Lemon</option>
<option value="lime">Lime</option>
</optgroup>
<optgroup label="Berries">
<option value="strawberry">Strawberry</option>
<option value="blueberry">Blueberry</option>
<option value="raspberry">Raspberry</option>
</optgroup>
<option value="apple" disabled>Apple (not available)</option>
</select>
<small id="fruitsHelp" class="help">Hold Ctrl (Windows) or
Command (Mac) to select multiple; Shift selects a range.</small>
</form>
Try selecting values in the dropdowns below, then click the buttons to preview what might be submitted as JSON data.
{ }
required.size to show enough options in a multi-select list box without scrolling too much.<optgroup> and use stable value tokens (not visible labels).multiple, ensure the backend understands repeated names (e.g., name="items[]").value attributes so translations or label changes don’t break form handling.<optgroup> sections to improve discoverability.<select> elements).selected and add a disabled option for “Coming soon” items.selectedOptions to an array (like in the example).<optgroup> sections and compare how quickly you can find items.<select> creates dropdowns or list boxes for choosing one or more predefined values.multiple, size, required, and name to control behavior and submission.<option> and <optgroup> define individual choices and logical groupings.