HTML <select> Tag

Advertisements


Description

The HTML <select> tag is used within a form for defining a select list.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML select Tag</title>
</head>
<body>
<form action="/cgi-bin/dropdown.cgi" method="post">
<select name="dropdown">
<option value="Data Structures" selected>Data Structures</option>
<option value="Data Mining">Data Mining</option>
</select>
<input type="submit" value="Submit" />
</form>
</body>
</html>

This will produce following result:

Global Attributes

This tag supports all the global attributes described in - HTML Attribute Reference

Specific Attributes

The HTML <select> tag also supports following additional attributes:

AttributeValueDescription
autofocus html-5autofocusSpecifies that on page load the drop-down list should automatically get focus.
disabled disabledDisables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
form html-5form_idSpecifies one or more forms.
multiple multipleWhen set, it specifies that multiple items can be selected at a time
name nameAssigns a name to the input control.s
required html-5requiredBefore submitting the form the user is required to select a value, else it won't proceed ahead.
sizenumberDefines the number of visible items in the drop-down list

Event Attributes

This tag supports all the event attributes described in - HTML Events Reference

Browser Support

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes

html_tags_reference.htm