HTML Tags

HTML <option> Tag

The <option> tag is used inside a <select> element to define a single option in a drop-down list.
Each <option> represents a selectable value that the user can choose.

The <option> tag must always be a child of <select> or <datalist>.

Syntax

<option value="value1" selected disabled>Option Text</option>

Attributes

AttributeDescription
valueThe value sent to the server when the option is selected.
selectedPreselects the option when the page loads.
disabledMakes the option unselectable.
labelProvides an alternative label for the option (for accessibility).
idAssigns a unique ID to the option element.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Option Tag Example</title>
</head>
<body>
  <h2>Select Your Favorite Color</h2>
  <form action="/samples/form_processor.php" method="post">
    <label for="colors">Choose a color:</label><br>
    <select name="colors" id="colors" required>
      <option value="">--Select--</option>
      <option value="red">Red</option>
      <option value="green" selected>Green</option>
      <option value="blue">Blue</option>
      <option value="yellow" disabled>Yellow (Unavailable)</option>
    </select><br><br>

    <input type="submit" value="Submit">
  </form>
</body>
</html>

Output

Browser Output

You will see a drop-down list where users can select a color.
The green option is preselected, and yellow is disabled and cannot be chosen.
Use our TryIt Editor to experiment with selected and disabled attributes.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

All major browser suppots <option> tag.

Notes

  • The <option> tag must be nested inside <select> or <datalist>.
  • Use selected to preselect an option.
  • Use disabled to prevent certain options from being selected.
  • For accessibility, the label attribute can provide a screen-reader-friendly name.

Conclusion

The <option> tag defines individual choices within a dropdown or list.
It is essential for creating dynamic, user-friendly selection interfaces in forms.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend