HTML <select> tag
Examples
Create a select list with four options:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
Browser Support
All major browsers support the <select> tag.
Tag definitions and instructions
<Select> element is used to create a drop-down list.
<select> element in the <option> tag defines the list of available options.
Tips and Notes
Tip: <select> element is a form control can be used to accept user input in the form.
Differences between HTML 4.01 and HTML5
HTML5 adds some new properties.
Attributes
New: HTML5 new property.
属性 | 值 | 描述 |
---|---|---|
autofocus New | autofocus | 规定在页面加载时下拉列表自动获得焦点。 |
disabled | disabled | 当该属性为 true 时,会禁用下拉列表。 |
form New | form_id | 定义 select 字段所属的一个或多个表单。 |
multiple | multiple | 当该属性为 true 时,可选择多个选项。 |
name | name | 定义下拉列表的名称。 |
required New | required | 规定用户在提交表单前必须选择一个下拉列表中的选项。 |
size | number | 规定下拉列表中可见选项的数目。 |
Global Properties
<select> tag supports HTML global properties .
Event Properties
<select> tag supports HTML event properties .
related articles
HTML DOM Reference Manual: the Select Object