Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 823121 of <datalist>

  • Revision slug: Web/HTML/Element/datalist
  • Revision title: <datalist>
  • Revision id: 823121
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment fixing broken spec link

Revision Content

Summary

The HTML Datalist Element (<datalist>) contains a set of {{HTMLElement("option")}} elements that represent the values available for other controls.

Attributes

This element has no other attributes than the global attributes, common to all elements.

Examples

<div>Choose a browser from this list:</div>
<input list="browsers" />
<datalist id="browsers">
  <option value="Chrome">
  <option value="Firefox">
  <option value="Internet Explorer">
  <option value="Opera">
  <option value="Safari">
</datalist>

Result

{{EmbedLiveSample("Examples")}}

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', 'the-button-element.html#the-datalist-element', '<datalist>')}} {{Spec2('HTML WHATWG')}}  
{{SpecName('HTML5 W3C', 'forms.html#the-datalist-element', '<datalist>')}} {{Spec2('HTML5 W3C')}}  

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 20 {{CompatGeckoDesktop("2.0")}} 10 9.5 {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 33 {{CompatGeckoMobile("2.0")}} {{CompatNo}} 10 {{CompatNo}}

See also

  • The {{HTMLElement("input")}} element, and more specifically its {{htmlattrxref("list", "input")}} attribute;
  • The {{HTMLElement("option")}} element.

{{HTMLRef}}

Revision Source

<h2 id="Summary">Summary</h2>

<p>The <em>HTML Datalist&nbsp;Element</em>&nbsp;(<strong>&lt;datalist&gt;</strong>) contains a set of {{HTMLElement("option")}} elements that represent the values available for other controls.</p>

<ul class="htmlelt">
 <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">Content categories</a></dfn> <a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">Flow content</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content categories#Phrasing content">phrasing content</a>.</li>
 <li><dfn>Permitted content</dfn> Either <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">phrasing content</a> or zero or more {{HTMLElement("option")}} elements.</li>
 <li><dfn>Tag omission</dfn> {{no_tag_omission}}</li>
 <li><dfn>Permitted parent elements</dfn> Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Phrasing_content">phrasing content</a>.</li>
 <li><dfn>DOM interface</dfn> {{domxref("HTMLDataListElement")}}</li>
</ul>

<h2 id="Attributes">Attributes</h2>

<p>This element has no other attributes than the <a href="/en-US/docs/HTML/Global_attributes" title="HTML/Global attributes">global attributes</a>, common to all elements.</p>

<h2 id="Examples">Examples</h2>

<pre class="brush: html">
&lt;div&gt;Choose a browser from this list:&lt;/div&gt;
&lt;input list="browsers" /&gt;
&lt;datalist id="browsers"&gt;
  &lt;option value="Chrome"&gt;
  &lt;option value="Firefox"&gt;
  &lt;option value="Internet Explorer"&gt;
  &lt;option value="Opera"&gt;
  &lt;option value="Safari"&gt;
&lt;/datalist&gt;
</pre>

<h3 id="Result" style="line-height: 24px; font-size: 1.71428571428571rem;">Result</h3>

<p>{{EmbedLiveSample("Examples")}}</p>

<h2 id="Specifications" name="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'the-button-element.html#the-datalist-element', '&lt;datalist&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'forms.html#the-datalist-element', '&lt;datalist&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>20</td>
   <td>{{CompatGeckoDesktop("2.0")}}</td>
   <td>10</td>
   <td>9.5</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>33</td>
   <td>{{CompatGeckoMobile("2.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>10</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li class="last">The {{HTMLElement("input")}} element, and more specifically its {{htmlattrxref("list", "input")}} attribute;</li>
 <li class="last">The {{HTMLElement("option")}} element.</li>
</ul>

<p class="last">{{HTMLRef}}</p>
Revert to this revision