Introduction
The HTML option tag is used for defining option items within a list. This element can be used in conjunction with the <select>
or <datalist> elements. Everything in an option tag will be displayed in the drop-down list. It is like a child of select tag, datalist, and optgroup tag.
Also, see <optgroup> tag for grouping your option items. The option tag is
supported in all major browsers.
Declaration Syntax : Declaration syntax
of <option> in HTML5.
<option attributes> Text </option >
Example
- <option disabled>HTML</option>
Attributes
Element-Specific Attributes
Attributes Introduced by HTML5
| Attributes | Description |
| disabled | This attribute specifies that the element represents a disabled control. |
| label | This attribute specifies a label for the option. |
| selected | This attribute specifies that the option should appear selected (will be displayed first in the list). |
| value | Specifies a value for the option. |
Global Attributes
|
HTML5 Global Attributes
|
||
| accesskey | draggable | style |
| class | hidden | tabindex |
| dir | spellcheck | title |
| contenteditable | id | |
| 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 |
Disabled attribute
A disabled option is unusable and un-clickable.
This attribute specifies that the element represents a disabled control.
Syntax
<option disabled="disabled">
For example
- <select>
- <option>-Select Color-</option>
- <option disabled="disabled" value="color">Red</option>
- <option value="color">Green</option>
- <option value="color">Pink</option>
- <option value="color">Blue</option>
- </select>
Label attribute
The label attribute specifies a shorter version of an
option. The shorter version will be displayed in the drop-down list.
Syntax
<option label="value">
For example


Join the conversation! Your thoughts help the community grow.