← 4.10.9 The select elementTable of contents4.10.11 The optgroup element →

4.10.10 The datalist element

Categories
Flow content.
Phrasing content.
Contexts in which this element can be used:
Where phrasing content is expected.
Content model:
Either: phrasing content.
Or: Zero or more option elements.
Content attributes:
Global attributes
DOM interface:
interface HTMLDataListElement : HTMLElement {
  readonly attribute HTMLCollection options;
};

The datalist element represents a set of option elements that represent predefined options for other controls. The contents of the element represents fallback content for legacy user agents, intermixed with option elements that represent the predefined options. In the rendering, the datalist element represents nothing.

The datalist element is hooked up to an input element using the list attribute on the input element.

Each option element that is a descendant of the datalist element, that is not disabled, and whose value is a string that isn't the empty string, represents a suggestion. Each suggestion has a value and a label.

datalist . options

Returns an HTMLCollection of the options elements of the table.