Hurry! Try our new Interactive Courses for FREE. 🥳   🚀
  Signup/Sign In

HTML Option Tag

In HTML, the <option> tag is used to define an item contained inside <select>, an <optgroup> or a <datalist> element.

  • The <option> tag is basically used to represent menu items in popups and lists of items in an HTML document.

  • The value attribute of the <option> tag is a bit important because it is used to send value to the server.

  • The <option> tag can also be used without using attributes.

HTML <option> Tag Syntax and Usage

The <option> tag requires both opening (start) tag and closing(end) tag.

The basic syntax for the same is given below:

<option>
...content here
</option>

HTML <option> Tag Attributes

The <option> tag supports both global and event attributes and some of the common attributes are given below:

1. Label

This attribute is used to indicate the text for the label which is used to define the meaning of option; If the label attribute is not defined than its value is that element text content.

2. Value

This attribute is used to specify the value of an option that is to be sent to the server.

3. Disabled

This attribute is used to specify that an option is disabled. It is a boolean attribute.

4. Selected

The value of this attribute is selected; this attribute is used to indicate that the option is preselected when the page gets loaded

HTML <option> Tag Basic Example

Below we have a basic example of <option> tag

Default CSS Settings for HTML <option> Tag

None

Browser Support for HTML <option> Tag

Following browsers support this attribute:

  • Google Chrome 6.0+

  • Internet Explorer 9.0+

  • Firefox 4+

  • Opera 11.1+

  • Safari 5.0+