Forms & Controls

HTML <datalist> element

Build a form with the HTML form generator

Provides suggested values for compatible controls through a matching list attribute. It does not generally restrict entries to the suggestions. The browser may render suggestions differently across devices and assistive technologies. A user can usually enter a value outside the list. Use select or explicit validation when only listed options are permitted. It accepts global HTML attributes; individual global features may be inapplicable or restricted.

Formal Syntax & Structure

html syntaxhtml
<datalist id="choices">  <option value="Option">  </datalist>

Return Value

HTMLDataListElement

Content model: Phrasing content or option elements, with script-supporting elements as allowed.

Working Example

Example Snippethtml
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <title>HTML example</title>  </head>  <body>    <label>      City      <input list="cities">    </label>    <datalist id="cities">      <option value="Stockholm">        <option value="Oslo">        </datalist>      </body>    </html>
HTML Reference