HTML <select> tag
In HTML document , the <select> tag element defines a drop down list.
It is mandatory to set at least one option for the drop down list.
So, you should code <option> tag inside this tag to display the list of options for the drop down.
Syntax:
<select> Content…</select>
Example
<select name="Mobiles"> <option value="SONY">SONY</option> <option value="APPLE">APPLE</option> <option value="HTC">HTC</option> <option value="NOKIA">NOKIA</option> <option value="SAMSUNG">SAMSUNG</option> <option value="MOTOROLA">MOTOROLA</option> </select>
How Browser will display
INLINE.
Difference between HTML4.01, XHTML and HTML5
In HTML5, there are some additional attributes. These are –
- form
- autofocus
- required
Attributes used with <select> tag
Attribute | Description |
---|---|
autocomplete | Defines whether form should have autocomplete on or off. |
autofocus | Added in HTML5. It defines that when page loads elements should get focus. |
disabled | It defines that specified element is disabled. |
form | Added in HTML5. The form attribute defines one or more forms for the elements belong to. |
multiple | It describes that given multiple option can be selected at a time. |
name | Sets a name for the drop-down. |
required | Added in HTML5. Informs the browser that the user must select a value for this field |
size | It describes the number of visible options. |
Global Attributes
The <select> tag supports Global attributes.
Event Attributes
The <select> tag supports Event attributes.
Supporting Browsers
Related Tags
<option> & <optgroup> tags.