<OPTION> | NN all IE all HTML all | |||
<OPTION>...</OPTION> | HTML End Tag: Optional | |||
The option element defines an item that appears in a select element listing, whether the listing is in a pop-up menu or scrolling list. option elements associated with a select element must be nested within the start and end tags of the select element. select elements supply name/value pairs when the element is submitted as part of a form element. Typically, the name attribute of the select element and the value attribute of the selected option are submitted as the name/value pair. Therefore, it is important to assign a meaningful value to the value attribute of each option element in a select list. You can use the value attribute to disguise user-unfriendly (but server- or script-friendly) values from the user, while presenting a user-friendly entry that appears in the select list. Content for the human-readable entry of a select list is entered after the option element's start tag. The end tag is optional because the entry is delimited either by the next option element start tag or the select element's end tag. See also the optgroup attribute for possible future grouping of option elements into hierarchical menu groupings. |
||||
Example | ||||
<SELECT name="chapters"> <OPTION value="1">Chapter 1</OPTION> <OPTION value="2">Chapter 2</OPTION> <OPTION value="3">Chapter 3</OPTION> <OPTION value="4">Chapter 4</OPTION> </SELECT> |
||||
Object Model Reference | ||||
[window.]document.formName.selectName.optionName [window.]document.forms[i].elements[j].options[k].optionName [window.]document.getElementById(elementID) |
||||
Element-Specific Attributes | ||||
|
||||
Element-Specific Event Handler Attributes | ||||
None. |
disabled | NN 6 IE 5/Mac HTML 4 |
disabled | Optional |
The presence of this attribute disables the option element in the list. Note that although the attribute disables the list choice in IE 5/Mac, as of Version 6, IE/Windows provides no other functionality for this attribute. |
|
Example | |
<OPTION value="Met101" disabled>Meteorology 101</OPTION> |
|
Value | |
The presence of this attribute sets its value to true. |
|
Default | |
false |
|
Object Model Reference | |
[window.]document.formName.selectName.optionName.disabled [window.]document.forms[i].elements[j].options[k].optionName.disabled [window.]document.getElementById(elementID).disabled |
label | NN n/a IE n/a HTML 4 |
label="labelText" | Required |
The label attribute is included in HTML 4.0 in anticipation of possible hierarchical select lists. The label is intended to be a shorter alternate entry for an option element when it is rendered hierarchically. It overrides the normal text associated with the option element. Note that IE 5/Mac incorrectly displays the label attribute value in lieu of the element's text. Version 6 browsers provide no practical functionality for this attribute. |
|
Example | |
<OPTION label="Meteo 101" value="met101">Meteorology 101</OPTION> |
|
Value | |
Any string of characters. The string must be inside a matching pair of (single or double) quotation marks. |
|
Default | |
None. |
lang | NN 3 IE 4 HTML 4 |
lang="languageCode" | Optional |
The language being used for the element's attribute values and content. A browser can use this information to assist in proper rendering of content with respect to details such as treatment of ligatures (when supported by a particular font or required by a written language), quotation marks, and hyphenation. Other applications and search engines might use this information to aid the selection of spell-checking dictionaries and the creation of indices. |
|
Example | |
<SPAN lang="de">Deutsche Bundesbahn</SPAN> |
|
Value | |
Case-insensitive language code. |
|
Default | |
Browser default. |
|
Object Model Reference | |
[window.]document.getElementById(elementID).lang
|
selected | NN all IE all HTML all |
selected | Optional |
The presence of the selected attribute preselects the item within the select element. When the select element is set to multiple, more than one option element may have the selected attribute set. |
|
Example | |
<OPTION value="met101" selected>Meteorology 101</OPTION> |
|
Value | |
The presence of this attribute sets its value to true. |
|
Default | |
false |
|
Object Model Reference | |
[window.]document.formName.selectName.optionName.selected [window.]document.forms[i].elements[j].options[k].selected [window.]document.getElementById(elementID).selected |
value | NN all IE all HTML all |
value="text" | Optional |
Associates a value with an option that may or may not be the same as the text displayed in the select element. When the select element is in a form submitted to the server, the value of the value attribute is assigned to the name/value pair for the select element if the option has been selected by the user (or is designated as selected with that attribute and the user has made no other selection). For scripting purposes, the value attribute might contain values such as URLs or string representations of objects that may subsequently be processed by scripts. |
|
Example | |
<OPTION value="met101">Meteorology 101</OPTION> |
|
Value | |
Any string of characters. The string must be inside a matching pair of (single or double) quotation marks. |
|
Default | |
None. |
|
Object Model Reference | |
[window.]document.formName.selectName.optionName.value [window.]document.forms[i].elements[j].options[k].optionName.value [window.]document.getElementById(elementID).value |