multiple
multiple attribute
The multiple
attribute in HTML enables users to select several files in a file input or multiple options from a dropdown menu. This improves the user experience by allowing multiple selections, making it more efficient to choose items like files or options in forms.
Syntax
<input type="file" multiple>
Example
- Example of a dropdown menu that allows users to select
multiple
options:
The multiple attribute specifies that multiple options can be selected at once:
Hold down the Ctrl (windows) or Command (Mac) button to select multiple options.
<h1>The select multiple attribute</h1>
<p>The multiple attribute specifies that multiple options can be selected at once:</p>
<form>
<label for="cars">Choose a car:</label>
<select name="cars" id="cars" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<br><br>
<input type="submit" value="Submit">
</form>
<p>Hold down the Ctrl (windows) or Command (Mac) button to select multiple options.</p>
Definition and Usage
The multiple
attribute is a boolean attribute.
When included, it enables the user to select or enter more than one value.
Values
- The
multiple
attribute is a boolean attribute, meaning it doesn't take any values when applied.
Applies To
The multiple
attribute can be used on the following html elements.
Conclusion
The multiple
attribute allows users to select more than one option or file at once, enhancing the flexibility of form inputs. It applies to elements like <input>
and <select>
. This attribute is especially useful for enabling bulk selection in file uploads or dropdown lists.
minlength
The HTML minlength attribute sets the minimum number of characters required in an input field, ensuring users provide a certain length of input before submitting the form.
pattern
The HTML pattern attribute defines a regular expression that the entered value must conform to, allowing for customized validation of text input fields.