<datalist>...</datalist>

HTML4 HTML5

Contains a set of suggested options (<option> tags) for input controls (usually <input>). Linked by matching the id of the <datalist> with the list attribute of the <input> field. Users can choose from the list or enter custom text.

Both opening and closing tags are required.

Attributes:

id="..." - (Required) Unique identifier used by an <input> element to bind options.

Example

Code:

<label for="browser">Choose a browser from the list or type your own:</label><br> <input list="browsers" name="browser" id="browser" placeholder="Start typing..." style="padding: 5px; margin-top: 5px; width: 200px;"> <datalist id="browsers"> <option value="Chrome"> <option value="Firefox"> <option value="Edge"> <option value="Safari"> <option value="Opera"> </datalist>

The browser will interpret this code as follows: