HTML Tag Reference - HTML tag <select>








This <select> tag creates a drop-down or pick list. The options displayed on the list are created by using the <option> element.

Browser compatibility

<select> Yes Yes Yes Yes Yes

What's new in HTML5

HTML5 has added some new attributes.

Attribute

Attribute Value Description
autofocus autofocus Set to autofocus the drop-down list when the page loads
disabled disabled disable drop-down list
form form_id Set one or more owner forms
multiple multiple Set that multiple options can be selected at once
name name Defines a name for the drop-down list
required required Mark the select element as required
size number Set the number of visible options in a drop-down list




Global Attributes

The <select> tag supports the Global Attributes in HTML.

Event Attributes

The <select> tag supports the Event Attributes in HTML.

Default CSS Settings

None.

Example

A demo showing how to use <select> tag.

<html>
<body>
     <form>
        <select name="select1">
               <optgroup label="First Group">
                    <option>First</option>
                    <option>second</option>
                    <option>third</option>
               </optgroup>
       </select>
     </form>
</body><!--   w w w.  j  a  va  2 s  .com-->
</html>

Click to view the demo