html5 Site Icon CSS3 Site Icon CSS Site Icon

HTML4 Reference

HTML <option> tag

Definition

The <option> tag is used to define a selectable option in a drop-down list.

Example


<select>
  <optgroup label="labelName">
    <option value="round">round</option>
    <option value="square">square</option>
  </optgroup>
</select>

Required Attributes

NONE

Optional Attributes

label - limited browser support - avoid this tag.

disabled - specifies the option will be disabled until a certain condition occurs.


<option disabled="disabled">Some text here</option>

selected - specifies the option will be selected and viewable by default.


<option selected="selected">Some text here</option>

value - specifies a value to send to the server instead of the element content.


<option value="someValue">Some text here</option>

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<option class="classname">Some text here</option>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<option id="idname">Some text here</option>

style - specifies an inline style for the element allowing you to apply the style to the content.


<option style="color:red;text-align:left">Some text here</option>

title - specifies extra information about the content.


<option title="information about the content">Some text here</option>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<option dir="ltr">Some text here</option>

<!-- The text will flow from right to left -->
<option dir="rtl">Some text here</option>

lang - specifies a language code for the content of the element.


<option lang="en">Some text here</option>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<option xml:lang="fr">Some text here</option>

Document Event Attributes

NONE

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<option onkeydown="go()">Some text here</option>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<option onkeypress="go()">Some text here</option>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<option onkeyup="go()">Some text here</option>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<option onclick="go()">Some text here</option>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<option ondblclick="go()">Some text here</option>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<option onmousedown="go()">Some text here</option>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<option onmousemove="go()">Some text heren</option>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<option onmouseout="go()">Some text here</option>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<option onmouseover="go()">Some text here</option>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<option onmouseup="go()">Some text here</option>


<optgroup> tag    << Prev          Next >>   <p> tag

go to home page Homepage go to top of page Top

HTML Elements

The complete set of HTML elements also known as HTML tags from the latest HTML 4.01 Specification.

Click the links for more information on individual tags and their attributes.

<!--...-->

<!DOCTYPE>

<a>

<abbr>

<acronym>

<address>

<applet>

<area />

<b>

<base />

<basefont />

<bdo>

<big>

<blockquote>

<body>

<br />

<button>

<caption>

<center>

<cite>

<code>

<col />

<colgroup>

<dd>

<del>

<dfn>

<dir>

<div>

<dl>

<dt>

<em>

<fieldset>

<font>

<form>

<frame />

<frameset>

<h1> - <h6>

<head>

<hr />

<html>

<i>

<iframe>

<img />

<input />

<ins>

<isindex />

<kbd>

<label>

<legend>

<li>

<link />

<map>

<menu>

<meta />

<noframes>

<noscript>

<object>

<ol>

<optgroup>

<option>

<p>

<param />

<pre>

<q>

<s>

<samp>

<script>

<select>

<small>

<span>

<strike>

<strong>

<style>

<sub>

<sup>

<table>

<tbody>

<td>

<textarea>

<tfoot>

<th>

<thead>

<title>

<tr>

<tt>

<u>

<ul>

<var>