HTML option Tag

HTML <option> Tag: The <option> tag in HTML is used to choose an option from a Drop-Down menu. This tag can be used with or without any attributes and needed value can be sent to the server. And the group of options can be created using <optgroup> Tag. It creates a group of related menu items.

HTML <option>Tag

This HTML option tag supports both the global and the event attributes.

Syntax: <option> Text </option>



Attributes

The <option> tag contains four attributes which are listed below:

  • disabled: This attribute contains the value disabled which represents option is disabled.
  • label: This attribute contains the text value which represents the shorted label for option.
  • selected: This attribute contains the value selected which represents the item is pre-selected when browser loaded.
  • value: This attribute contains the value text sent to the server.

Browser compatibility

The HTML<option>tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer

Example:

<!DOCTYPE html>
<html>
<body>
<select>
  <option value="html">HTML</option>
  <option value="css">CSS</option>
  <option value="c">C</option>
  <option value="java">JAVA</option>
</select>  
</body>
</html>

Output:

html option tag

Attributes that are supported by the <option> tag

Attribute Value Description
disabled disabled Describes that an option must be deleted
label text Describes a shorter label for an option
selected selected Describes that an option must be pre-selected when the page loads
value text Describes the value to be sent to a server