select – option-selection form control # T
The
select
element
represents a control for selecting among a list of
options.
Permitted contents #
zero or more optgroup elements,
intermixed with zero or more option elements
Permitted attributes #
-
global attributes
- Any attributes permitted globally.
-
name = string
#
- The name part of the name/value pair associated with this
element for the purposes of form submission.
-
disabled =
"disabled"
or "" (empty string) or empty
#
- Specifies that the element represents a disabled
control.
-
form =
ID reference
NEW
#
- The value of the
id
attribute on the
form
with which to associate the element.
-
size =
positive integer
#
- The number of options to show to the user.
-
multiple =
"multiple"
or "" (empty string) or empty
#
- If present, indicates that its
select
element represents a control for selecting zero or more
options from a list of options.
- If not present, indicates that its
select
element represents a control
for selecting a single option from a list of options.
-
autofocus =
"autofocus"
or "" (empty string) or empty
NEW
#
- Specifies that the element represents a control to which
a UA is meant to give focus as soon as the document is
loaded.
-
required =
"required"
or "" (empty string) or empty
NEW
#
- Specifies that the element is a required part of form
submission.
Additional constraints and admonitions #
-
The interactive element select must not
appear as a descendant of the a element.
-
The interactive element select must not
appear as a descendant of the button element.
-
Any select element descendant of a label element
with a for attribute must have an
ID value that matches that for attribute.
-
The select element cannot have more than one
selected option element descendant unless the
multiple attribute is specified.
Permitted parent elements #
any element that can contain
phrasing elements
DOM interface #
interface HTMLSelectElement : HTMLElement {
attribute boolean autofocus;
attribute boolean disabled;
readonly attribute HTMLFormElement form;
attribute boolean multiple;
attribute DOMString name;
attribute boolean required;
attribute unsigned long size;
readonly attribute DOMString type;
readonly attribute HTMLOptionsCollection options;
attribute unsigned long length;
getter any item(in unsigned long index);
any namedItem(in DOMString name);
void add(in HTMLElement element, in optional HTMLElement before);
void add(in HTMLElement element, in long before);
void remove(in long index);
readonly attribute HTMLCollection selectedOptions;
attribute long selectedIndex;
attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
readonly attribute NodeList labels;
};