Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <input> list Attribute

The list attribute on an <input> tag associates the input element with a <datalist>.

A datalist provides a list of suggested values to the input control.

Example

#

A list attribute on an <input> element. A datalist with colors is associated with the textbox. Click the textbox to see the color options.

Color  
 <datalist id="colors">
   <option value="Red">
   <option value="Green">
   <option value="Yellow">
   <option value="Purple">
   <option value="Blue">
 </datalist>

<form action="/tutorial/action.html">
  Color &nbsp; <input list="colors" name="color"><br/>

  <input type="submit">
</form>


Using list

The list attribute specifies the id of a <datalist> with suggested values.

Suggested values are only suggestions. The user can still enter any other value.

On the other hand, a dropdown control (<select>), does not allow custom values being entered.


Syntax

<input list="datalist-id">

Values

#

Value Description
datalist-id The id of the <datalist> element.

Browser support

Here is when list support started for each browser:

Chrome
20.0 Jun 2012
Firefox
4.0 Mar 2011
IE/Edge
10.0 Sep 2012
Opera
9.6 Oct 2008
Safari
Not Supported

You may also like

 Back to <input>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides