Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

OPTION - an option in a select menu

Purpose

To present one option in a select menu within a form.

Typical rendering

When the enclosing select menu is activated, the user can see the text of the option, either as part of a list of such text or by scanning through the options.

Basic syntax

<OPTION>text</OPTION>

The end tag can always be omitted.

Possible attributes

attribute name possible values meaning notes
SELECTED SELECTED the option is selected by default in a SELECT element without the MULTIPLE attribute, at most one OPTION element may have this set
VALUE string property value to be used when submitting the contents of the form; this is combined with the property name as given by the NAME attribute of the enclosing SELECT element defaults to the contents of the element; however, several browsers ignore leading and/or trailing spaces in the content

According to the HTML 2.0 specification, "the initial state has the first option selected, unless a SELECTED attribute is present on any of the OPTION elements". On the other hand, the HTML 3.2 Reference Specification leaves the default initial state open, so it is safest to assume that it is browser-dependent (and it actually is). You may wish to deal with this problem by providing a dummy first option (e.g. "No selection") and making it SELECTED, thus ensuring the same behavior from all HTML 3.2 conformant browsers. See Choices in HTML forms for more info.

Allowed context

SELECT element.

Contents

A string. Escape sequences are allowed, but no tags are recognized.

Examples

<OPTION>female</OPTION>


Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.