HTML5: How to refer to a datalist element that contains pre-defined options for an input element?
Solution :
HTML Code:
Explanation:
- This HTML code demonstrates how to refer to a datalist element that contains pre-defined options for an input element.
- The form element is defined with method set to "post" and action set to the URL where the form data should be sent.
- Inside the form, there is an input field with the name "animal" and a list attribute referencing the ID of the datalist element.
- The datalist element with ID "animal" contains pre-defined options such as Lion, Tiger, and Elephant.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.