Forms & Controls
HTML <select> element
Provides a selection control with option children, optionally grouped with optgroup. multiple allows selecting more than one value. Use a label and meaningful option values. A single-select normally chooses one option; multiple permits multiple selections. Traditional and customizable select markup differ and the latter needs compatibility testing. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<select name="choice"> <option value="a">A</option></select>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| autocomplete | ordered autofill tokens or on/off | Gives the browser the purpose of a form field or controls autofill. Use meaningful tokens such as email or current-password. A browser may still offer password-manager autofill even with off. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| multiple | boolean | Allows multiple files, comma-separated email addresses or multiple select options depending on the element. It does not apply to ordinary text inputs. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| size | positive integer | Visible option count, not a maximum number of selected items. |
Return Value
HTMLSelectElement
Content model: Traditional controls use option, optgroup and optional hr; customizable select allows additional specified markup.
Working Example
Example Snippethtml
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <label> Format <select name="format"> <option>Paperback</option> <option>E-book</option> </select> </label> </body></html>