<select>


HTML <select> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
  
</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

All major browsers support< select> tag.


Tag definition and usage instructions

<select> element is used to create a drop-down list.

The <option> tag in the<select> element defines the options available in the list.


Tips and Notes

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


Differences between HTML 4.01 and HTML5

HTML5 adds some new attributes.


Attributes

New: New attributes in HTML5.

PropertiesValueDescription
autofocusNew autofocus Specifies that the drop-down list automatically gains focus when the page loads.
disableddisabledWhen this property is true, the drop-down list is disabled.
formNewform_idDefine one or more forms to which the select field belongs.
multiplemultipleWhen this property is true, multiple options can be selected.
namenameDefine the name of the drop-down list.
requiredNewrequired Specifies that the user must select an option from a drop-down list before submitting the form.
sizenumberSpecifies the number of visible options in the drop-down list.


Global attributes

<select> tag supports global attributes of HTML.


Event attributes

<select> tag supports HTML event attributes.


Related articles

HTML DOM Reference Manual: Select object