Computer >> Computer tutorials >  >> Programming >> HTML

How to refer to a <datalist> element that contains pre-defined options for an <input> element in HTML?


Use the list attribute for <datalist> element that contains pre-defined options for an <input> element in HTML. You can try to run the following code to implement the list attribute −

Example

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Datalist Tag</title>
   </head>
   <body>
      <input list = "tutorials" />
      <datalist id = "tutorials">
         <option value = "Java">
         <option value = "ASP">
         <option value = "PHP">
         <option value = "Ruby">
         <option value = "jQuery">
      </datalist>
      <p>Try to add any of the tutorial name mentioned above.</p>
   </body>
</html>