HTML select multiple Attribute (2024)

❮ HTML <select> tag

Example

A drop-down list that allows multiple selections:

<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>

Try it Yourself »

Definition and Usage

The multiple attribute is a boolean attribute.

When present, it specifies that multiple options can be selected at once.

Selecting multiple options vary in different operating systems and browsers:

  • For windows: Hold down the control (ctrl) button to select multiple options
  • For Mac: Hold down the command button to select multiple options

Because of the different ways of doing this, and because you have to inform the user that multiple selection is available, it is more user-friendly to use checkboxes instead.

Browser Support

Attribute
multiple Yes Yes Yes Yes Yes

Syntax

<select multiple>

❮ HTML <select> tag

W3schools Pathfinder

Track your progress - it's free!

HTML select multiple Attribute (2024)

FAQs

How to use multiple attributes in select tag in HTML? ›

Definition and Usage

The multiple attribute is a boolean attribute. When present, it specifies that multiple options can be selected at once. Selecting multiple options vary in different operating systems and browsers: For windows: Hold down the control (ctrl) button to select multiple options.

How do you create a multi select in HTML? ›

Multiple List Selections. Adding the multiple attribute to <select> allows the user to select more than one option. The user will need to hold down the ctrl or cmd key to select more than one option in the list, so you will need to add some explanatory text.

How do you select more than one value in HTML? ›

In such cases, all you have to do is use the <select> tag with the multiple attribute, and then the user will have to hold down the ctrl key on Windows, or its alternative for other OS, while making their selections. This is just like when you want to make multiple highlights and copies on your system.

How do I select multiple values in a dropdown in HTML? ›

With the multiple attribute, you can allow the user to select multiple items from the dropdown. This makes 4 items visible by default. To select multiple items, the user has to hold down the shift or ctrl key, then select with the mouse.

How do I create a multi-select dropdown? ›

How to make Excel drop down with multiple selections
  1. Select one or more cells for your dropdown (D3:D7 in our case).
  2. On the Data tab, in the Data Tools group, click Data Validation.
  3. In the Allow drop-down box, select List.
  4. In the Source box, enter the formula that indirectly refers to Table1's column named Items.
Feb 5, 2024

Can you have multiple data attributes in HTML? ›

Idea here is multiple attributes can be set to an HTML element by assigning Map object (key-value pairs) to data-sly-attribute. Based on how you design/decide to get the input from author in a dialog, retrieve data accordingly and populate Map object.

Which input type is used for multiple selection in HTML? ›

The multiple attribute is a boolean attribute. When present, it specifies that the user is allowed to enter more than one value in the <input> element. Note: The multiple attribute works with the following input types: email, and file.

What is a multiple select dropdown? ›

Dropdown lists are one of the most flexible elements in HTML. It is similar to that of the radio input, that is, only one item can be selected from a group of items by default. However, when the multiple attribute is used with the <select> element, we can enable the selection of multiple options from the list.

Which input type is used for multiple selection? ›

HTML 5 has a property for input tag which is 'multiple'. Below example illustrates the above approach: Example: Using this property, you can input multiple files. For selecting files, you must use either CTRL or SHIFT and select the number of files to be uploaded.

How to use select value in HTML? ›

The <select> element is most often used in a form, to collect user input. The name attribute is needed to reference the form data after the form is submitted (if you omit the name attribute, no data from the drop-down list will be submitted). The id attribute is needed to associate the drop-down list with a label.

How to use multiple Select2 in single page? ›

You can make a “multiple” Select2 behave like a “single” Select2 by programmatically replacing the existing selections with the new selection. Create an event handler for the “select2:select” event. In your event handler, set the current value to the new selection, replacing any existing selections. Hi John!

Can a dropdown have multiple values? ›

With a dropdown select, it is only possible to select one option. If you want the ability to select more than one option, you'll want to use a Multiple Checkbox property type.

How to create multi select dropdown in HTML Javascript? ›

  1. import { MultiSelect } from '@syncfusion/ej2-dropdowns';
  2. // initialize MultiSelect component.
  3. let msObject: MultiSelect = new MultiSelect();
  4. // render initialized MultiSelect.
  5. msObject. appendTo('#select');

How to select multiple tags in CSS? ›

With the grouping selector, you can target and style more than one element at once. To use the grouping selector, use a comma, , to group and separate the different elements you want to select. The code above matches all div , p , and span elements on the page, and those three elements will share the same styling.

How do I add a dropdown in HTML? ›

How to Create an HTML Dropdown List
  1. // Syntax <select name="" id=""> <option value="">...</ option> // ... </ ...
  2. // Syntax <label for="languages">List of Languages:</label> <select name="" id="languages"> <option value="">...</ option> // ... </ ...
  3. <select name="" id="languages" required> // ... </
Sep 26, 2022

Can we use multiple attributes in CSS selector? ›

Multiple attribute selectors can be used to refer to several attributes of an element, or even several times to the same attribute. As a side note, using quotation marks around an attribute value is required only if this value is not a valid identifier.

How do I add multiple attributes to a single tag? ›

When present, it specifies that the user is allowed to enter more than one value in the <input> element. Note: The multiple attribute works with the following input types: email, and file. Tip: For <input type="file"> : To select multiple files, hold down the CTRL or SHIFT key while selecting.

Can we add multiple style attributes for a single tag in HTML? ›

You can add as many styles as you need by separating them with semicolons.

How do I SELECT multiple attributes in SQL? ›

To select multiple columns from a table, simply separate the column names with commas! For example, this query selects two columns, name and birthdate , from the people table: SELECT name, birthdate FROM people; Sometimes, you may want to select all columns from a table.

Top Articles
Latest Posts
Article information

Author: Arline Emard IV

Last Updated:

Views: 5814

Rating: 4.1 / 5 (52 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Arline Emard IV

Birthday: 1996-07-10

Address: 8912 Hintz Shore, West Louie, AZ 69363-0747

Phone: +13454700762376

Job: Administration Technician

Hobby: Paintball, Horseback riding, Cycling, Running, Macrame, Playing musical instruments, Soapmaking

Introduction: My name is Arline Emard IV, I am a cheerful, gorgeous, colorful, joyous, excited, super, inquisitive person who loves writing and wants to share my knowledge and understanding with you.