HTML <input> list Attribute

Last Updated : 26 May, 2026

The list attribute is used to connect an <input> element with a <datalist> element. It provides users with a list of predefined input suggestions.

  • Links an input field to a <datalist> using its id.
  • Displays predefined suggestions while the user types.
  • Improves user experience by allowing faster and easier input selection.

Syntax: 

<input list="datalist_id">

Attribute Values: 

  • datalist_id: It is used to specify the Id of the datalist that will used to make a link up with the input element.
html
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>

<head>
    <title>
      HTML Input list Attribute
  </title>
</head>

<body>
    <h1>
        GeeksForGeeks
    </h1>
    <h1 style="color:green">
      HTML Input list Attribute
  </h1>

<!--Driver Code Ends-->

    <form action="">
        <label>Your Cars Name: </label>
        <input list="cars">
        <datalist id="cars">
            <option value="BMW" />
            <option value="Bentley" />
            <option value="Mercedes" />
            <option value="Audi" />
            <option value="Volkswagen" />
        </datalist>
    </form>

<!--Driver Code Starts-->
</body>

</html>

<!--Driver Code Ends-->
Comment