html Option Tag

In the html <option> tag is used to identify option in the <select> list.you can use <option> tag inside of <datalist> or <select> tag. In the new features introduced in html that is <option> tag should use inside of <datalist> tag.

In the <option> tag can use with out any attribute but normally we will use value attribute for data value sent to server.All main browsers are supported in <option> tag. Which tag has no end tag and xhtml the <option> tag should be close properly.

Disabled attribute is used to disable for option and label attribute is used to label for option and selected attribute is used to select for drop down list and value attribute is used to data sent for server.

Optional attributes are disabled,label,selected and value and standard attributes are class, dir , id, lang, style and xml:lang and event attributes are onclick, ondblclick.

Syntax:

<select>
  <option> ... </option>
</select>

Example Code

Car Name Lists
<select>
  <option value ="Achieva">Achieva</option>
  <option value ="Baja">Baja</option>
  <option value ="Caballero" selected>Caballero</option>
  <option value ="Cheyenne">Cheyenne</option>
</select>

Out Put:



Car Name Lists

In the above select box example <option> tag has been added to car name lists.




Content