HTML <option> tag

HTML <option> tag is used to define options in a dropdown list within <select> or <datalist> element. A dropdown list must have at least one <option> element.

The related <option> of a dropdown list can be grouped using <optgroup> element which helps to understand a large list.

Tips: The <option> tag can be used without any attribute, but it should be used with value attribute which specifies what send to the server.

Syntax

Following are some specifications about the HTML <option> tag

DisplayInline
Start tag/End tagBoth Start and End tag
UsageForms and Inputs

Example

Test it Now

Output:

HTML option tag

Attribute:

Tag-specific attributes:

AttributeValueDescription
disableddisabledIf it is set then that option will be disabled.
labeltextIt defines the name for the list item.
selectedselectedIf it is set, then it will be selected by default in the list.
valuetextIt specifies the data which is sent to the server.

Global attribute:

HTML <option> tag supports the global attributes in HTML

Event attribute:

HTML <option> tag supports the event attributes in HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<option>YesYesYesYesYes
Next TopicHTML output Tag