Option HTML

HTML <option> Tag

Within a <select> or <datalist> element, we can define options in a dropdown list using the HTML <option> tag. Each dropdown list in HTML contains at least one <option> element.


<option value="">.....</option>


<!DOCTYPE html>
<h3> Select an Option:</h3>
    <option value="Apple">Apple</option>
    <option value="Mango">Mango</option>
    <option value="Pineapple">Pineapple</option>
    <option value="Papaya">Papaya</option>


In the above example, we are using the HTML <option> tag to add options to a dropdown list.

Tag specific attributes:

Attribute Value Uses
disabled disabled Used to disable an option.
label text Used to specify the name for the list item.
selected selected Used to pre-select an option, when the page loads.
value text Used to define the value which is sent to the server.

Global attributes:

The HTML global attributes are supported by the HTML <option> tag.

Event attributes:

The HTML event attributes are supported by the HTML <option> tag.

Supporting Browsers:

Chrome, IE, Firefox, Opera, and Safari.