Datalist element in HTML 5Datalist is added in HTML 5. This element is used inside a form to receive data from user.
Here is the demo of Datalist.
Difference between Datalist and Options of a dropdown list boxOptions : User can select one of the options of a list box.
Datalist : In datalist user can select one or can enter anything other than the available choices.
When to use DatalistWhen we give user the choice to enter data other than the available list then datalist to be used.
If we don’t want user to enter anything other than available list then go for options.
Example of DatalistWe ask user to enter the name of the town they are staying. We are not sure of having a list of all the towns as option to select by the user. Here user can select the town name if available or can enter a new town which is not available in our list of towns.
Datalist is a powerful tool for developers. Here are some of the applications.