HTML/Elements/datalist

From Web Education Community Group
< HTML‎ | Elements
Jump to: navigation, search

<datalist>

The <datalist> element represents the list that represent predefined options for other controls.

Point

  • The value of an option element in a datalist element represent a suggestion.


  • The datalist element is hooked up to an input element using the list attribute on the input element. [Example A]

HTML Attributes

See global attributes.


Examples

Example A

[try it]:

<input type="text" name="city" list="cityname">
<datalist id="cityname">
  <option value="Boston">
  <option value="Cambridge">
</datalist>


HTML Reference

The HTML5 specification defines the <datalist> element in 4.10.10 The datalist element.