HTML <select> Tag with the 'multiple' Attribute
<form id="myForm" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
<select name="Food" multiple>
<option value ="apples">Apples</option>
<option value ="bananas">Bananas</option>
<option value ="oranges">Oranges</option>
<option value ="cabbage">Cabbage</option>
<option value ="carrots">Carrots</option>
<option value ="potatoes">Potatoes</option>
<option value ="beef">Beef</option>
<option value ="chicken">Chicken</option>
<option value ="pork">Pork</option>
</select>
<button>Submit</button>
</form>
The above example demonstrates usage of the <select>
element with the multiple
attribute.
The multiple
attribute allows the user to select multiple options from the <select>
list. They can select one, many, or all items.
Typically, the list will display multiple options when the page loads and the user will usually need to hold down a key while selecting multiple options. For example, on a Mac, the user might press the Shift key to select contiguous items, and the Command key to select non-contiguous items. He might also be able to select all items by using Command|All.
Boolean Attribute
The multiple
attribute is a boolean attribute. If it is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either multiple
or multiple="multiple"
).
Possible values:
- [Empty string]
- multiple
You can also use the size
attribute to specify how many options to display.