Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

multiple — multiple values in a form control

The boolean `multiple` attribute permits multiple options in `select`, multiple addresses in an `email` input, or multiple files in a `file` input. Its presence controls the behavior, not the text of its value.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

select: multiple; input[type=email]: multiple; input[type=file]: multiple. Boolean forms: multiple | multiple="" | multiple="multiple".

multiple is a boolean attribute: its presence enables the behavior and its absence disables it. Valid forms are multiple, multiple="", and multiple="multiple". Writing multiple="false" is invalid and still enables the behavior because the attribute remains present. Remove the attribute to disable it.

On select, it permits zero or more options to be selected; without it, the control is for selecting a single option. It does not automatically select all options. The size attribute determines how many options are visible, not the selection limit.

On an email input, it permits a list of addresses separated by commas, not semicolons. On a file input, it allows multiple files to be selected; without it, the selected-file list can contain at most one file. It is not a general mechanism for entering multiple values in other input types.

The example has two options with the selected attribute. The script reads the multiple property and the values from selectedOptions, then displays the initial result. No manual selection is required.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>multiple example</title>
<label for="topics">Topics</label>
<select id="topics" multiple>
  <option value="html" selected>HTML</option>
  <option value="css" selected>CSS</option>
</select>
<pre id="result"></pre>
<script>
  const topics = document.getElementById('topics');
  const values = Array.from(topics.selectedOptions, option => option.value);
  document.getElementById('result').textContent =
    `${topics.multiple}\n${values.join(',')}`;
</script>
</html>

Result

true
html,css

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources