HTML DATALIST Tag
The DATALIST tag is used to display the list of the predefined options that the user may want to select as input. This tag enables the auto complete feature on the forms. This means that when a user start typing in a text box, a list of predefined words is dropped down to choose.
The DATALIST tag is used with the INPUT tag, in which the list attribute is specified. The value of the list attribute is similar to the id attribute of the DATALIST tag to link the INPUT tag with the DATALIST tag.
The OPTION tag used as the child tag of the DATALIST tag is used to specify the list of the options that are to be displayed.
DATALIST Tag Example
Following is an example of using the DATALIST tag.
<INPUT type="text" list="name"> <DATALIST id="name"> <OPTION value="Richard"> <OPTION value="John"> <OPTION value="Tony"> </DATALIST>
Here, we have used the INPUT tag and the DATALIST tag. We have specified the same value for the list attribute of the INPUT tag and the id attribute of the DATALIST tag. We have also defined the OPTION tags and specified their value attributes as the options to be displayed.
« Previous Tutorial Next Tutorial »
Follow/Like Us on Facebook
Subscribe Us on YouTube