The HTML5 option Tag
The purpose of adding HTML5 <option> tag is to indicate option within a list selected by the author. The HTML5 <option> tag has to be placed inside the <select> or <datalist> element or else, it would not work properly for the document.
The use of HTML5 <option> tag is slightly different in HTML4.01 and HTML5. For HTML5, the <option> element is also applicable for the new <datalist> element.
Compatibility with major web browsers is not an issue since HTML5 <option> tag is read by the major web browsers like Internet Explorer, Firefox, Opera, Google Chrome and Safari. It is also applicable for both the Global Attributes and Events Attributes in HTML5.
The attributes for HTML5 <option> tag are listed below:
Attribute |
Value |
Description |
disabled |
disabled |
This is the key in disabling the option |
label |
text |
It is used when shorter label has to be used for the option |
selected |
selected |
Enables an option to be pre-selected as soon as the page loads up |
value |
text |
It is used in indicating the value which has to be sent to the server |