I was wondering what the differences are between Select-Option and Datalist-Option. Is there any situation in which it would be better to use one or the other? An example of each follows:
<select name="browser"> <option value="firefox">Firefox</option> <option value="ie">IE</option> <option value="chrome">Chrome</option> <option value="opera">Opera</option> <option value="safari">Safari</option> </select>
<input type=text list=browsers> <datalist id=browsers> <option value="Firefox"> <option value="IE"> <option value="Chrome"> <option value="Opera"> <option value="Safari"> </datalist>
This question is related to
Think of it as the difference between a requirement and a suggestion. For the
select element, the user is required to select one of the options you've given. For the
datalist element, it is suggested that the user select one of the options you've given, but he can actually enter anything he wants in the input.
Edit 1: So which one you use depends upon your requirements. If the user must enter one of your choices, use the
select element. If the use can enter whatever, use the
Edit 2: Found this tidbit in the HTML Living Standard: "Each option element that is a descendant of the datalist element...represents a suggestion."