HTML option element

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

Example

<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>
Try </>

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

Related tags

AttributesDescription
<select> select tag represents a list of options.
<select> <option> ... </option> </select>

Tag omission

End tag of option element may be omitted.

Global Attributes

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

Specific Attributes

AttributesDescription
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?

 

Email:

Message:

Get the newsletter