Select Tag in HTML5


The select element creates a drop-down list. This element is used in conjunction with the <option> element to produce a list of options that the user can choose from. The <select> tag is supported in all major browsers. You can use <optgroup> tag within <select> tag for grouping option.
</select >


HTML tags can contain one or more attributes. Attributes are added to a tag to provide the browser with more information about how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign, with the value surrounded by double-quotes.
There are 3 kinds of attributes that you can add to your HTML tags: Element-specific, global, and event handler content attributes. The attributes that you can add to this tag are listed below.

Element-Specific Attributes

The following table shows the attributes that are specific to this tag/element.
Attributes Introduced by HTML5
Attributes Description             
autofocus (New) Automatically gives focusto this control when the page loads. This allows the user to start usingthe control without having to select it first.
disabled Disables the inputcontrol. The button won't accept changes from the user.
multiple When present, it specifiesthat multiple items can be selected at a time.
Name Defines a unique name forthe drop-down list.
size Defines the number ofvisible items in the drop-down list.

Global Attributes

The following attributes are standard across all HTML 5 tags.
HTML5Global Attributes
accesskey draggable style
class hidden tabindex
dir spellcheck  
contenteditable id title
contextmenu lang  

Event Handler Content Attributes

Here are the standard HTML 5 event handler content attributes.
onabort onerror* onmousewheel
onblur* onfocus* onpause
oncanplay onformchange onplay
oncanplaythrough onforminput onplaying
onchange oninput onprogress
onclick oninvalid onratechange
oncontextmenu onkeydown onreadystatechange
ondblclick onkeypress onscroll
ondrag onkeyup onseeked
ondragend onload* onseeking
ondragenter onloadeddata onselect
ondragleave onloadedmetadata onshow
ondragover onloadstart onstalled
ondragstart onmousedown onsubmit
ondrop onmousemove onsuspend
ondurationchange onmouseout ontimeupdate
onemptied onmouseover onvolumechange
onended onmouseup onwaiting

autofocus (New) 

This is a new attribute in HTML5. This tag is used to automatically gives focus to this control when the page loads.
<select autofocus="autofocus">
For Example
  1. <select autofocus="autofocus">  
  2.     <option value="volvo">-Select Color-</option>  
  3.     <option value="volvo">Red</option>  
  4.     <option value="saab">Green</option>  
  5.     <option value="opel">Pink</option>  
  6.     <option value="audi">Blue</option>  
  7. </select>  

Disabled attribute

The disabled attribute specifies that a drop-down list should be disabled. A disabled drop-down list is unusable and un-clickable.
<select disabled="disabled">
For Example
  1. <select disabled ="disabled">  
  2.     <option value="volvo">-Select Color-</option>  
  3.     <option value="volvo">Red</option>  
  4.     <option value="saab">Green</option>  
  5.     <option value="opel">Pink</option>  
  6.     <option value="audi">Blue</option>  
  7. </select>  

Multiple Attribute

The multiple attribute specifies that multiple options can be selected at the same time.
<select multiple="multiple">
For Example
  1. <select multiple="multiple" name="D1">  
  2.     <option value="volvo">-Select Color-</option>  
  3.     <option value="volvo">Red</option>  
  4.     <option value="saab">Green</option>  
  5.     <option value="opel">Pink</option>  
  6.     <option value="audi">Blue</option>  
  7. </select>  

Size Attribute

The size attribute specifies the number of visible options in a drop-down list.
<select size="value">
For Example
  1. <select size="3">  
  2.     <option value="volvo">-Select Color-</option>  
  3.     <option value="volvo">Red</option>  
  4.     <option value="saab">Green</option>  
  5.     <option value="opel">Pink</option>  
  6.     <option value="audi">Blue</option>  
  7. </select>  

Using all Attribute

For Example
  1. <html>  
  2.     <body>  
  3.         <table style="width: 49%">  
  4.             <tr>  
  5.                 <td>  
  6.             Disabled attribute  
  7.         </td>  
  8.                 <td>  
  9.                     <select disabled="disabled">  
  10.                         <option value="volvo">-Select Color-</option>  
  11.                         <option value="volvo">Red</option>  
  12.                         <option value="saab">Green</option>  
  13.                         <option value="opel">Pink</option>  
  14.                         <option value="audi">Blue</option>  
  15.                     </select>  
  16.                 </td>  
  17.             </tr>  
  18.             <tr>  
  19.                 <td>  
  20.             AutoFocus Attribute  
  21.         </td>  
  22.                 <td>  
  23.                     <select autofocus="autofocus">  
  24.                         <option value="volvo">-Select Color-</option>  
  25.                         <option value="volvo">Red</option>  
  26.                         <option value="saab">Green</option>  
  27.                         <option value="opel">Pink</option>  
  28.                         <option value="audi">Blue</option>  
  29.                     </select>  
  30.                 </td>  
  31.             </tr>  
  32.             <tr>  
  33.                 <td>  
  34.             Multiple Attribute  
  35.         </td>  
  36.                 <td>  
  37.                     <select multiple="multiple" name="D1">  
  38.                         <option value="volvo">-Select Color-</option>  
  39.                         <option value="volvo">Red</option>  
  40.                         <option value="saab">Green</option>  
  41.                         <option value="opel">Pink</option>  
  42.                         <option value="audi">Blue</option>  
  43.                     </select>  
  44.                 </td>  
  45.             </tr>  
  46.             <tr>  
  47.                 <td>  
  48.             Size Attribute  
  49.         </td>  
  50.                 <td>  
  51.                     <select size="3">  
  52.                         <option value="volvo">-Select Color-</option>  
  53.                         <option value="volvo">Red</option>  
  54.                         <option value="saab">Green</option>  
  55.                         <option value="opel">Pink</option>  
  56.                         <option value="audi">Blue</option>  
  57.                     </select>  
  58.                 </td>  
  59.             </tr>  
  60.         </table>  
  61.     </body>  
  62. </html>  
Internet explorer
Fire Fox