Tutorials Point


  HTML Home

  HTML Tags Reference
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

HTML <option> tag




Advertisements

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:

AttributeValueDescription
disableddisabledDisables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
labeltextDefines a label to use when using <optgroup>.
selectedselectedDefines the default option to be selected when page loads.
valuetextSpecifies the value of the option to be sent to the server

Standard Attributes:

AttributeDescription
classDocument wide identifier
dirSpecifies the direction of the text
idDocument wide identifier
titleSpecifies a title to associate with the element.
styleHelps to include inline casecadubf style sheet.
langSets the language code.
xml:langSets the language code.
tabindexHelps determine the tabbing order

Event Attributes:

AttributeDescription
onclickScript runs when a mouse click
ondblclickScript runs when a mouse double-click
onmousedownScript runs when mouse button is pressed
onmouseupScript runs when mouse button is released
onmouseoverScript runs when mouse pointer moves over an element
onmousemoveScript runs when mouse pointer moves
onmouseoutScript runs when mouse pointer moves out of an element
onkeypressScript runs when key is pressed and released
onkeydownScript runs when key is pressed
onkeyupScript runs when key is released

Printer Friendly

Advertisements


  

Advertisements