CKTIS / HTML
select — selection control
The `select` element lets users choose among form options. Learn single and multiple selection, labeling, and the role of `name` when submitting data.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<select name="field" id="field"><option value="value">Label</option></select>select offers a choice among option elements. Without multiple, it provides single selection; with multiple, it allows zero or more options to be selected. size specifies the number of visible entries.
Associate a label with the control using matching for and id values. name is the form-data key, whereas id identifies the control, not its submission key. Each selected, enabled option contributes its value; with multiple, the key can repeat. A control with disabled is omitted.
For required single selection with a display size of 1, the first option must serve as a placeholder: it must have an empty value, and its parent must be the select itself, not an optgroup or any other element. Selecting only that option does not satisfy required.
The example initially selects the dark option. Its script reads form data without sending it to a server. The result represents the initial state; it does not update when the selection changes.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Select example</title>
<form id="settings">
<label for="theme">Theme</label>
<select id="theme" name="theme" required>
<option value="">Choose a theme</option>
<option value="light">Light</option>
<option value="dark" selected>Dark</option>
</select>
</form>
<pre id="result"></pre>
<script>
const form = document.getElementById('settings');
const data = new FormData(form);
document.getElementById('result').textContent = data.get('theme');
</script>
</html>Result
dark
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.