HTML <select> Tag
Example: In this example, we simply create a drop-down list in HTML.
The <select> tag in HTML is used to create a drop-down list. The <select> tag contains <option> tag to display the available option of drop-down list.
Note: The <select> tag is used in a form to receive user responses.
<select> <option> </option> ... </select>
Attributes: The attributes of the <select> tag are listed below:
- autofocus: The HTML <select> autofocus Attribute is used to specify that the dropdown should automatically get focus when the page loads. It is a type of boolean attribute.
- disabled: The <select> disabled attribute is used to specify the select element is disabled. A disabled drop-down list is un-clickable and unusable. It is a boolean attribute.
- form: The HTML <select> form attribute is used to specify one or more forms that the <select> element belongs to.
- multiple: The HTML <select> multiple attribute is a Boolean Attribute. It specifies that the user is allowed to select more than one value that presents in <select> element.
- required: The HTML <select> required attribute is a Boolean attribute that is used to specify that the user should be selected value before submitting the Form.
- size: The HTML size attribute is used to specifies the number of visible options in a drop-down list.
Example: In this example, we are using optgroup tag with select tag. optgroup tag is used for displaying related options in the drop-down list.
- Google Chrome
- Internet Explorer
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.