HTML 5 <option> Tag
Example
A drop-down list with four options:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select> |
Try it yourself »
|
Definition and Usage
The option element defines an option in the drop-down list.
Differences Between HTML 4.01 and HTML 5
In HTML 5, the <option> element is also used in the new element <datalist>.
Tips and Notes
Note: The <option> tag can be used without any attributes, but
you usually need the value attribute, which indicates what is sent to the
server.
Note: Use this tag in conjunction with <select> or <datalist>
elements, elsewhere
it is meaningless.
Attributes
| Attribute |
Value |
Description |
| disabled |
disabled |
Specifies that the option should be disabled when it first
loads |
| label |
text |
Defines a label to use when using <optgroup> |
| selected |
selected |
Specifies that the option should appear selected (will be
displayed first in the list) |
| value |
text |
Defines the value of the option to be sent to the
server |
Standard Attributes
| class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title |
For a full description, go to Standard Attributes in HTML 5.
Event Attributes
| onabort, onbeforeunload, onblur, onchange, onclick,
oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave,
ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress,
onkeyup, onload, onmessage, onmousedown, onmousemove,
onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect,
onsubmit, onunload |
For a full description, go to Event Attributes in HTML 5.
|