HTML option element

HTML <option> tag defines an option as a child of select or datalist elements.

<p>If you are given a chance to visit one of the following countries,then what will be your choice?</p>
 <select>
  <option> Germany 
  <option> Canada 
  <option> New Zealand 
  <option> Australia
  <option> Egypt
 </select>
</>

If you are given a chance to visit one of the following countries,then what will be your choice?

select element offers a list of different options. We select one option out of these options. Here, you can omit the end tag (</option>).

Tag omission

End tag of option element may be omitted.

Global Attributes

All the global attributes are applicable on the <option> element.

Tag Attributes

Attributes that are applicable to <option> tag
disabled

disabled attribute disables the option element.

<select> <option disabled> ... </option> </select>
label

label attribute defines label or caption of the option element.

<select> <option label="text"> ... </option> </select>
selected

It is a boolean attribute. By default, That option is selected which contains the selected attribute.

<select> <option selected> ... </option> </select>
value

value attribute represents the user visible content.

<select> <option value="text"> ... </option> </select>


Was this article helpful?