XHTML Reference: option

The XHTML WYSIWYG Editor For Desktop & Web Applications

option

Definition

The option element represents a choice offered by select form controls.

Example

  1. <form method="post" action="survey.php">
  2. <p>
  3. <label for="question">What's your sign?</label><br />
  4. <select name="sign" id="question" size="12">
  5. <option value="1">Aries</option>
  6. <option value="2">Taurus</option>
  7. <option value="3">Gemini</option>
  8. <option value="4">Cancer</option>
  9. <option value="5">Leo</option>
  10. <option value="6">Virgo</option>
  11. <option value="7">Libra</option>
  12. <option value="8">Scorpio</option>
  13. <option value="9">Sagittarius</option>
  14. <option value="10">Capricorn</option>
  15. <option value="11">Aquarius</option>
  16. <option value="12">Pisces</option>
  17. </select>
  18. </p>
  19. </form>

Attributes

Basic

selected
When set, this attribute specifies that an option is pre-selected. Possible value is selected.
value
(Text) Value associated with a selection option.

Advanced

disabled
Disables an option in a list of selectable options. Possible value is disabled.
label
(Text) Shorter label.

Common core attributes

class
(NameTokens) This attribute assigns a class name or set of class names to an element. Any number of elements may be assigned the same class name or set of class names. Multiple class names must be separated by white space characters. Class names are typically used to apply CSS formatting rules to an element.
id
(ID) This attribute assigns an ID to an element. This ID must be unique in a document. This ID can be used by client-side scripts (such as JavaScript) to select elements, apply CSS formatting rules, or to build relationships between elements.
title
(Text) This attribute offers advisory information. Some Web browsers will display this information as tooltips. Assistive technologies may make this information available to users as additional information about the element.

Common internationalization attributes

xml:lang
(NameToken) This attribute specifies the base language of an element's attribute values and text content.
dir

This attribute specifies the base direction of text. Possible values:

  • ltr: Left-to-right
  • rtl: Right-to-left

Common event attributes

onclick
(Script) A client-side script event that occurs when a pointing device button is clicked over an element.
ondblclick
(Script) A client-side script event that occurs when a pointing device button is double-clicked over an element.
onmousedown
(Script) A client-side script event that occurs when a pointing device button is pressed down over an element.
onmouseup
(Script) A client-side script event that occurs when a pointing device button is released over an element.
onmouseover
(Script) A client-side script event that occurs when a pointing device is moved onto an element.
onmousemove
(Script) A client-side script event that occurs when a pointing device is moved within an element.
onmouseout
(Script) A client-side script event that occurs when a pointing device is moved away from an element.
onkeypress
(Script) A client-side script event that occurs when a key is pressed down over an element then released.
onkeydown
(Script) A client-side script event that occurs when a key is pressed down over an element.
onkeyup
(Script) A client-side script event that occurs when a key is released over an element.

Common style attribute

style
(Text) This attribute specifies formatting style information for the current element. The content of this attribute is called inline CSS. The style attribute is deprecated (considered outdated), because it fuses together content and formatting.

Contains

  • Text

See also