HTML Datalist Tag <datalist> is used to define a list of pre defined values for HTML input tag <input>.
By using the Datalist Tag user will be able to see a list of values as they enter data in the textbox.
HTML Datalist Tag <datalist> is a closed tag and needs to be closed using HTML Datalist closing Tag </datalist>.
Note: Datalist tag is new in HTML 5.
Syntax of HTML Datalist Tag
<datalist> <option value =”Value 1”> <option value =”Value 2”> . . . <option value =”Value N”> </datalist>
Example of HTML Datalist Tag
HTML Datalist Tag | Output |
<input list="browsers" name="browser"> <datalist id="browsers"> <option value="Windows 7"> <option value="Windows 8"> <option value="Red Hat"> <option value="Ubuntu"> <option value="Mac OS X"> </datalist> |
As we can see in the output of HTML Datalist Tag we can see that there is a list of value which is rendered containing the values of various operating systems.
HTML Datalist Tag supports all HTML Global Attributes and HTML Event Attributes.
HTML Datalist Tag Supporting Browsers
S. No. | Browser | Supported(Yes/No) |
1 | Internet Explorer | Yes (above IE 9) |
2 | Firefox | Yes |
3 | Google Chrome | Yes |
4 | Opera | Yes |
5 | Safari | No |