HTML5 <select> Tag

Example

Create a select list with four options:

<select>
  <option value ="Sachin">Sachin</option>
  <option value ="Ganguly">Ganguly</option>
  <option value ="Maxwell">Maxwell</option>
  <option value ="white">white</option>
</select>
Code it Online »

Definition and Usage

The select element creates a drop-down list.

The <option> tags inside the select element define the available options in the list.

Differences Between HTML 4.01 and HTML5

HTML5 has some new attributes.

Tips and Notes

Hint: The select element is a form control and can be used in a form to collect user input.

Attributes

Attribute Value Description
autofocus autofocus Makes the select field focused on page load
disabled disabled When true, it disables the drop-down list
form formname Defines one ore more forms the select field belongs to.
multiple multiple When present, it specifies that multiple items can be selected at a time
name unique name Defines a unique name for the drop-down list
size number Defines the number of visible items in the drop-down list.

Standard Attributes

The <option> tag also supports the Standard Attributes in HTML5.

Event Attributes

The <option> tag also supports the Event Attributes in HTML5.


Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!