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

 

Featured pages

Overview

Learn about HTML5 architecture, design principles and patterns on HTML5 Overview Tutorial. Become …

Tags

Learn about HTML5 tags and discover a new list of HTML5 tags. Find out about HTML5 tags support by…

Welcome

 Learn HTML5 development techniques, tips and tricks on our website. Find out what is required…

Date Time Picker

HTML5 forms use date and time controls regularly. HTML5 date and time controls are used by booking …