<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
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.
Properties | Value | Description |
---|---|---|
autofocusNew | autofocus | Specifies that the drop-down list automatically gains focus when the page loads. |
disabled | disabled | When this property is true, the drop-down list is disabled. |
formNew | form_id | Define one or more forms to which the select field belongs. |
multiple | multiple | When this property is true, multiple options can be selected. |
name | name | Define the name of the drop-down list. |
requiredNew | required | Specifies that the user must select an option from a drop-down list before submitting the form. |
size | number | Specifies 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