Copyright © tutorialspoint.com

# HTML <option> tag

## Function:

The HTML <option> tag is used within a form for defining options in the drop-down list.

## Difference between HTML and XHTML:

NONE

## Example:

    <form action="/cgi-bin/dropdown.cgi" method="post">
    <select name="dropdown">
    <option value="Maths" selected>Maths</option>
    <option value="Physics">Physics</option>
    </select>
    <input type="submit" value="Submit" />
    </form>

This will produce following result:

## Online Practice:

To Become more comfortable - Do Online Practice

## Attributes:

Attribute | Value | Description
--- | --- | ---
disabled | disabled | Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
label | text | Defines a label to use when using <optgroup>.
selected | selected | Defines the default option to be selected when page loads.
value | text | Specifies the value of the option to be sent to the server

## Standard Attributes:

Attribute | Description
--- | ---
class | Document wide identifier
dir | Specifies the direction of the text
id | Document wide identifier
title | Specifies a title to associate with the element.
style | Helps to include inline casecadubf style sheet.
lang | Sets the language code.
xml:lang | Sets the language code.
tabindex | Helps determine the tabbing order

## Event Attributes:

Attribute | Description
--- | ---
onclick | Script runs when a mouse click
ondblclick | Script runs when a mouse double-click
onmousedown | Script runs when mouse button is pressed
onmouseup | Script runs when mouse button is released
onmouseover | Script runs when mouse pointer moves over an element
onmousemove | Script runs when mouse pointer moves
onmouseout | Script runs when mouse pointer moves out of an element
onkeypress | Script runs when key is pressed and released
onkeydown | Script runs when key is pressed
onkeyup | Script runs when key is released

Copyright © tutorialspoint.com