HTML Tag Reference - HTML tag <option>








This <option> element is used to create a list item in a <select> element list.

Browser compatibility

<option> Yes Yes Yes Yes Yes

What's new in HTML5

None.

Attribute

Attribute Value Description
disabled disabled disable an option
label text Set a shorter label for an option
selected selected pre-selected an option when the page loads
value text Set the value to be sent to a server




Global Attributes

The <option> tag supports the Global Attributes in HTML.

Event Attributes

The <option> tag supports the Event Attributes in HTML.

Default CSS Settings

None.

Example

A demo showing how to use <option> tag.

<html>
<body>
     <form>
          <select name="select1">
              <optgroup label="First Group">
                   <option>First</option>
                   <option>second</option>
                   <option>third</option>
              </optgroup>
          </select>
     </form>
</body><!--from  w  w w  .  j a  v a  2 s.  com-->
</html>

Click to view the demo