April 2013
Intermediate to advanced
264 pages
7h 44m
English
Where elements accept text input—such as text, url, or search—you can provide a list of helpful suggestions to the user. The browser can offer these based on the user’s previous input (controlled by the previously mentioned autocomplete attribute), but at times you may want to suggest a range of predefined terms. Implement this latter option with the datalist element.
The datalist element contains a list of suggestions, each of which is contained in an option child element (which you should be familiar with from the select element in HTML 4.01). To illustrate what I mean, here’s a short datalist with only a few options:
<datalist id="apes"> <option>Chimpanzee</option> <option>Gorilla, Eastern</option> <option>Gorilla, Western</option> ...
Read now
Unlock full access