HTML Tags

HTML <datalist> Tag

The <datalist> tag is used to provide a list of predefined options for an <input> element.
It allows users to type a value or select from a list, offering a flexible and user-friendly input experience.

The <datalist> element must be linked to an <input> using the list attribute.

Syntax

<input list="listId" name="inputName" id="inputId">
<datalist id="listId">
  <option value="Option 1">
  <option value="Option 2">
</datalist>

Attributes

AttributeDescription
idUnique identifier for the datalist, used by the list attribute of <input>.
nameRarely used, specifies the name of the datalist.

Example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Datalist Example</title>
</head>
<body>
  <h2>Choose Your Favorite Browser</h2>
  <form action="/samples/form_processor.php" method="post">
    <label for="browser">Browser:</label>
    <input list="browsers" id="browser" name="browser" placeholder="Start typing..." required>
    <datalist id="browsers">
      <option value="Chrome">
      <option value="Firefox">
      <option value="Edge">
      <option value="Safari">
      <option value="Opera">
      <option value="Internet Explorer">
    </datalist><br><br>

    <input type="submit" value="Submit">
  </form>
</body>
</html>

Output

Browser Output

You will see a text input where users can either type or select a value from a suggested dropdown list.
As the user types, matching options appear for selection.
Try it in our TryIt Editor to see how <datalist> enhances form input.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

All major browser supports <datalist> tag

Notes

  • The <datalist> provides autocomplete suggestions but does not restrict input to only the listed options.
  • Must be linked to an <input> element via the list attribute.
  • Improves user experience for forms with common or repetitive inputs.
  • Works best for short lists; for very long lists, consider <select> instead.

Conclusion

The <datalist> tag creates a dynamic, user-friendly input experience.
It is widely supported and enhances form usability by providing autocomplete suggestions.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend