<option> tag

HTML <option> tag

The <option> tag displays option in drop down list.

The <option> element is nested inside the <select> or <datalist> element.

Syntax:
<option value=”text”>some text….</option>

Example

<select>
  <option value="SONY">SONY</option>
  <option value="APPLE">APPLE</option>
  <option value="HTC">HTC</option>
  <option value="NOKIA">NOKIA</option>
  <option value="SAMSUNG">SAMSUNG</option>
  <option value="MOTOROLA">MOTOROLA</option>
</select>

Default value

NONE

How Browser will display

INLINE.

Difference between HTML4.01, XHTML and HTML5

HTML4 XHTML HTML5
None None None

Attributes used with <option> tag

Attribute Description
label Defines a label for the options
disabled Disables all the options from the drop down.
selected It will automotically preselect an option when you load the page.
value Defines the value of the element to send to the server

Global Attributes

The <option> tag supports global attributes.

Event Attributes

The <option> tag supports event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<select>, <datalist>, <select>, <form>, <fieldset>, <legend>, <textarea>, <input>, <label>, <button> and <optgroup> tags.

Tutorials for all brains!