English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <select> tag

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.

Online Example

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 ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <select> tag.

Definition and Usage Description

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.

Tips and Notes

Tip:<select> element is a form control that can be used to accept user input in a form.

HTML 4.01 and HTML5Differences between

HTML5 Some new attributes have been added.

Attribute

New: HTML5 New attributes added to

AttributeValueDescription
autofocusHTML5autofocusSpecifies that the dropdown list will automatically gain focus when the page is loaded.
disableddisabledWhen this attribute is true, the dropdown list will be disabled.
formHTML5form_idSpecifies one or more forms that the select field belongs to.
multiplemultipleWhen this attribute is true, multiple options can be selected.
nametextDefines the name of the dropdown list.
requiredHTML5requiredSpecifies that a user must select an option from the dropdown list before submitting the form.
sizenumberSpecifies the number of visible options in the dropdown list.

Global Attributes

<select> tag supports HTML Global Attributes.

Event Attributes

<select> tag supports HTML Event Attributes.

Related Articles

HTML DOM Reference Manual: Select Object