What is the datalist tag in HTML ?

  • In HTML <datalist> tag is used to provide autocomplete feature in the files.
  • Users can easily fill the data in the forms using select the data because it is used by an input tag.
  • It provides a list of predefined options for the users to select data.

Sample Code

<!DOCTYPE html>
<html>
<body>

<h1>The datalist element</h1>

<form action="/action_page.php" method="get">
  <label for="browser">Choose your browser from the list:</label>
  <input list="browsers" name="browser" id="browser">
  <datalist id="browsers">
    <option value="Edge">
    <option value="Firefox">
    <option value="Chrome">
    <option value="Opera">
    <option value="Safari">
  </datalist>
  <input type="submit">
</form>

<p><strong>Note:</strong> The datalist tag is not supported in Safari 12.0 (or earlier).</p>

</body>
</html>

Output

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

What is a marquee tag ?

In HTML it is used to create scrolling text or image in a webpage. It scrolls either from vertically top to bottom or bottom to top or horizontally left to…
View Answer

How to Align Text in HTML ?

By using markup language, HTML is used to design webpages. It defines the link between the webpages. It defines the structure of webpages where markup language is used to define…
View Answer

How do you add buttons in HTML ?

In HTML <button> tag is used to clickable button within form on your webpage. We can put content like image or text within the <button>to</button> tag. For <button> tag we should…
View Answer