What is the < \ datalist > tag used for?
Used to provide a "autocomplete" feature in form elements. It allows you to provide a list of predefined options to the user as they enter data.
For example, if a user starts inserting some text into a textfield, a list would be suspended with pre-filled values that they could choose.
<datalist> tag can be used in conjunction with a
<input> element that contains a
An example of a
<input> element with default values in a
<form action="formulario_cor.php" method="post">
<label for="cor">Qual sua cor favorita? </label>
<input list="cor" name="cor" >
<input type="submit" />
Is this tag new?
According to w3schools documentation , the
<datalist> tag is new to HTML5.
Somehow, it can replace the functionality of
"autocomplemento" that currently exist in several
Thanks to the Datalist tag, it will no longer be necessary to use
jQuery or some other
If, for example, we have an entry where the user must include his / her country (as in the example above), we can add the list by datalist element, which provides users with certain suggestions filled or limited only to countries that are accepted for registration.