English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <select> element represents a control that creates a drop-down list for users to select. These drop-down values are defined by a series of <option> tags within the <select> tag. This tag is also commonly referred to as the <select> element.
Create a drop-down list with multiple options:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML select tag usage (Basic Tutorial Website oldtoolbag.com)</title> </head> <body> <label for="pet-select>Choose a pet:</label> <select name="pets" id="pet-select> <option value="">--Please choose an option--</option> <option value="dog">Dog</option> <option value="cat">Cat</option> <option value="hamster">Hamster</option> <option value="parrot">Parrot</option> <option value="spider">Spider</option> <option value="goldfish">Goldfish</option> </select> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the <select> tag.
The <select> element is used to create a drop-down list.
within the <select> element <option> Tags that provide a drop-down value list and available options.
By default, the first option in the <select> tag is displayed as the selected item. Users can select another option from the drop-down list.
Tip:<select> element is a form control that can be used to accept user input in a form.
HTML5 Some new attributes have been added.
New: HTML5 New attributes added to
Attribute | Value | Description |
---|---|---|
autofocusHTML5 | autofocus | Specifies that the dropdown list will automatically gain focus when the page is loaded. |
disabled | disabled | When this attribute is true, the dropdown list will be disabled. |
formHTML5 | form_id | Specifies one or more forms that the select field belongs to. |
multiple | multiple | When this attribute is true, multiple options can be selected. |
name | text | Defines the name of the dropdown list. |
requiredHTML5 | required | Specifies that a user must select an option from the dropdown list before submitting the form. |
size | number | Specifies the number of visible options in the dropdown list. |
<select> tag supports HTML Global Attributes.
<select> tag supports HTML Event Attributes.
HTML DOM Reference Manual: Select Object