HTML datalist tag

Last Updated on April 26, 2023 by Roshan Parihar

HTML datalist tag is used to show some pre-defined options for the users to select for input field.


Syntax

Output

Few list of html tags to select by the user.




List of HTML datalist tag attributes

Sr. No. Datalist attributes Description
1 id Used to include an id for datalist. This id should be same as value of list attributes in the input field.
2 value Used to give value of <options> tag used inside datalist tag.

HTML Datalist tag with input type, color

This example for datalist contains an input field with a type attribute value color. This can be used in web pages to show the list of colors to select by the user.

Output




Example for HTML datalist tag with an input type range

This example for datalist contains an input field with a type attribute value range. This can be used in web pages to show the list of ranges to select by the user. This is not the replacement of HTML list tag.

Output




Resources and References

1. W3C Specification.
2. HTML living standard
3. W3C project using Github