HTML Tutorial
The <option>
tag is used to create options in a <select>
dropdown list. It defines the text and value of each option.
<option>
To create an <option>
tag, use the following syntax:
<option value="value">text</option>
where:
value
is the value of the option (optional)text
is the text displayed for the option<option>
The <option>
tag supports the following attributes:
<option>
<option value="option1">Option 1</option>
<option value="option2" selected>Option 2</option>
<option value="option3" disabled>Option 3</option>
Exploring the <option>
tag (Example)
<form>
<label for="options">Select an option:</label>
<select id="options">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3" selected>Option 3</option>
</select>
<input type="submit" value="Submit">
</form>
In this example, the <option>
tag is used to create three options in a dropdown list. The third option is selected by default using the selected
attribute.