HTML option Tag defines the list of options for the drop down menu. HTML option tag is used inside the select tag. User can select one or more options at a time.
Table of Contents
Syntax of HTML option Tag
The Syntax of HTML option Tag is shown below, It has both starting tag and ending tag.
<option>
</option>
Usage of HTML option Tag
HTML option Tag is used to make a drop down list or menu. This drop down menu contains more than one options. The option tag is used to list options inside the select tag.
option tag is also used inside the optgroup tag and datalist tag. The optgroup tag defines the group of same types of options. While datalist tag defines pre-defined options for the input tag.
Example of HTML option Tag
Simple example of HTML option Tag is given below.
<select name="languages">
<option value='html'>HTML</option>
<option value='css'>CSS</option>
<option value='javascript'>JavaScript</option>
<option value='php'>PHP</option>
</select>
In above example we have used option tags to make a drop down list of web languages.
value attribute is used to define values for each option which will be stored in database.
selected attribute is used to specify the pre-selected option, this option will be selected automatically once the page loads.
Output
Output of above code is shown below.
Browser Support for HTML option Tag
HTML option Tag is supported by all major browsers which include Chrome, Opera, Firefox, Edge, Internet Explorer and Safari.
Global Attributes Support in HTML option Tag
The HTML option Tag supports all Global Attributes.
Event Attributes Support in HTML option Tag
The HTML option Tag supports all Event Attributes.
HTML option Tag Video
Watch our video on HTML option Tag.