Web Platform Atlas
EN⚡RUUA⚡DE⚡FR⚡ES⚡PL⚡PT⚡ZH⚡JA⚡
Каталог / HTML / The datalist element

4.10.8 The datalist element

Статический предпросмотр (RU): для MDN, WPT, глоссария и BYOK-перевода откройте интерактивный Атлас.
⚡ Открыть главу в Атласе

4.10.8 The datalist element

Категории:

потоковое содержимое.

Фразовое содержимое.

Контексты, в которых может использоваться этот элемент:

Где ожидается Фразовое содержимое.

Контентная модель:

Either: phrasing content.

Or: Zero or more option and script-supporting elements.

Опущение тегов в text/html:

Ни один из тегов не может быть опущен.

Атрибуты контента:

глобальные атрибуты

Специфика доступности:

Для авторов.

Для разработчиков.

Санитизация:

Uncategorized.

DOM-интерфейс:

[Exposed=Window] interface HTMLDataListElement : HTMLElement { [HTMLConstructor] constructor(); [SameObject] readonly attribute HTMLCollection options; };

The datalist element represents a set of option elements that represent predefined options for other controls. In the rendering, the datalist element represents nothing and it, along with its children, should be hidden.

The datalist element can be used in two ways. In the simplest case, the datalist element has just option element children.

<label> Animal: <input name=animal list=animals> <datalist id=animals> <option value="Cat"> <option value="Dog"> </datalist> </label>

In the more elaborate case, the datalist element can be given contents that are to be displayed for down-level clients that don't support datalist. In this case, the option elements are provided inside a select element inside the datalist element.

<label> Animal: <input name=animal list=animals> </label> <datalist id=animals> <label> or select from the list: <select name=animal> <option value=""> <option>Cat <option>Dog </select> </label> </datalist>

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 option elements of the datalist element.

The options IDL attribute must return an HTMLCollection rooted at the datalist node, whose filter matches option elements.

Constraint validation: If an element has a datalist element ancestor, it is barred from constraint validation.