References

Collection of references for web development.

HTML option tag

Description

The HTML <option> element represents an option in a <select>, <datalist>, or <optgroup> element.

Attributes

Attribute Value Description
disabled boolean Specifies whether the element should be disabled or not (user is unable to click or control if disabled).
label string Specifies the name or meaning of the element.
selected boolean Specifies whether the option is selected or not.
value value Specifies the value of the element.

Example

<select>
	<option value="m">Male</option>
	<option value="f" selected>Female</option>
</select>

Example #2

<select>
	<optgroup label="vegetables">
		<option>Carrots</option>
		<option>Potatoes</option>
		<option>Spinach</option>
	</optgroup> 
	<optgroup label="fruit">
		<option>Apples</option>
		<option>Bananas</option>
	</optgroup> 
</select>