HTML <option> Tag
In this tutorial, we will learn about option tag in HTML with the help of examples.
<option> Tag
Option tag <option> is used to defines an option in a select list.
Note : The <option> tag can be used inside a <select>, <optgroup>, or <datalist> tag.
Syntax
<option>.........</option>
Example
<!DOCTYPE html>
<html>
<head>
<title>Option Tag</title>
</head>
<body>
<select>
<optgroup label = "Computer Languages">
<option value = "html">HTML</option>
<option value = "css">CSS</option>
<option value = "javascript">Javascript</option>
</select>
</body>
</html>
Output
Specific Attribute
Attribute | Value | Description |
---|---|---|
disable | disable | It is used to disable the input control. The button won't accept changes from the user |
label | text | It defines a label to use when using <optgroup> tag |
selected | selected | It defines the default option to be selected when page loads |
value | text | It specifies the value of the option to be sent to the server |
Global Attribute
Option Tag support all the global attributes of HTML.
Event Attribute
Option Tag support all the event attributes of HTML.
Next Tutorial
We hope that this tutorial helped you develop better understanding of the concept of <option> tag in HTML.
Keep Learning : )
In the next tutorial, you'll learn about HTML <output>
Tag.