May 03, 2021 HTML5
HTML5 is used to implement a pull-down list. Please refer to the following example:
Create a selection list with 4 options:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
All major browsers support the label.
The element is used to create a pull-down list.
The label in the element defines the options available in the list.
Tip: The element is a form control that can be used to accept user input in a form.
HTML5 adds some new properties.
New: The new property in HTML5.
Property | Value | Describe |
---|---|---|
autofocus New | autofocus | Provides that the downlier list automatically gets focus when the page loads. |
disabled | disabled | When the property is true, the pull-down list is disabled. |
form New | form_id | Define one or more forms to which the select field belongs. |
multiple | multiple | When the property is true, you can select more than one option. |
name | name | Define the name of the pull-down list. |
required New | required | Specifies that the user must select an option in the drop-down list before submitting the form. |
size | number | Specify the number of options visible in the drop-down list. |
The label supports the global properties of HTML.
The tag supports the event properties of HTML.
HTML DOM Reference Manual: Select Object
HTML Reference Manual: Ultra-detailed introduction to HTML and the use and techniques of tags