👀 Live Preview
A simple fruit dropdown with a label:

The <select> tag creates dropdown menus in HTML forms. This guide covers syntax, option elements, attributes, labels, multiple selection, accessibility, and best practices for beginners.
Pick from a list.
List choices.
Form submission.
Multi-select.
Accessible forms.
Clear options.
<select> Tag?The <select> tag is an HTML form element that allows users to choose one or more options from a predefined list. It is commonly used to create dropdown menus, providing a user-friendly way to select values in forms.
Pair select with option children. Use a label so users and screen readers know what the dropdown is for.
Each option represents one choice. The value attribute is sent when the form is submitted; the text between the tags is what users see.
Wrap option elements inside a select element:
<select>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<!-- Add more options as needed -->
</select><label for="country">Country:</label>
<select id="country" name="country">
<option value="us">United States</option>
<option value="uk">United Kingdom</option>
</select>value on each option for form submission.name on select so the chosen value is included in form data.label with for matching the select’s id.selected on an option to pre-select the default choice.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic dropdown | <select><option>...</option></select> | Single choice |
| Form field name | name="fruit" | On select |
| Option value | value="apple" | Submitted data |
| Multiple select | multiple | Hold Ctrl/Cmd |
| Visible rows | size="3" | List box style |
| Default choice | selected | On option |
<select> vs <datalist>| Feature | select | datalist |
|---|---|---|
| Input type | Native dropdown | Suggestions on text input |
| Free text | No — must pick a listed option | Yes — user can type anything |
| Validation | Browser enforces options | Server-side recommended |
| Best for | Country, size, category pickers | Autocomplete with flexible input |
The <select> tag supports attributes to customize behavior and appearance in forms:
<select name="example" multiple size="3">
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>name FormsIdentifies the field when the form is submitted.
name="country"multiple SelectionAllows users to select more than one option.
multiplesize DisplayNumber of visible options when expanded or in list-box mode.
size="3"required ValidationUser must select a value before the form can be submitted.
requireddisabled StatePrevents interaction. Use on select or individual options.
disabledselected On optionMarks the default selected option on page load.
<option selected>Build dropdown lists and multi-select controls with select and option elements.
A simple fruit dropdown with a label:
Use <select> when users must pick from a fixed list of predefined options.
Create a simple dropdown with the select tag and option elements:
<label for="fruit">Choose a fruit:</label>
<select id="fruit" name="fruit">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="orange">Orange</option>
</select>Allow users to select multiple options by adding the multiple attribute. Pair with size for a clearer list-box UI:
<label for="colors">Choose colors:</label>
<select id="colors" name="colors" multiple size="4">
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
</select>label for to the select’s id so screen readers announce the field purpose.optgroup with a label attribute for long categorized lists.disabled, not just styled differently.select displays options from child option elements.
Click or keyboard navigation selects one or more option values.
The name and selected value are sent to the server.
Users pick from a controlled list, making data collection predictable and easy.
The <select> tag is supported in all major browsers, including Internet Explorer.
All browsers support <select> with multiple, size, and disabled options.
Bottom line: Use <select> confidently for dropdowns in any browser.
Understanding the <select> tag is crucial for creating interactive and user-friendly forms on your website. By mastering its usage and attributes, you can enhance the overall user experience and make data submission more intuitive.
labelsize with multiple for better usabilityname attribute on form selectsdatalist when choices must be strictdisabled for unavailable choices<select>Bookmark these before you build your next form.
Pick from list.
PurposeEach choice.
ChildrenForm field.
AttributesMulti-pick.
SelectionAccessible.
A11yAll browsers.
Compatibilityselect restricts choices to listed options. datalist suggests options but allows free text.multiple attribute. Use size to show several rows for easier selection.name identifies the field when the form is submitted so the server receives the selected value.Practice <select> with basic dropdowns, multiple, and form attributes in the Try It editor.
6 people found this page helpful