- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <datalist> Tag
Introduction to <datalist> Tag
The HTML <datalist> tag is used to define a list of pre-defined options for the <input> element, enabling the user to select from a set of suggestions while still allowing custom input. It improves the user experience by providing the autocomplete functionality.
The <datalist> tag works in conjunction with the list attribute of the <input> element. Every suggestion within in a <datalist> is defined by using the <option> tag.
The <datalist> tag is supported in most of the modern browsers, but the fallback strategies should be considered for the older browsers.
Syntax
Following is the syntax of HTML <datalist> tag −.
<datalist>....</datalist>
Attributes
HTML datalist tag supports Global and Event attributes of HTML.
Example : Basic Usage
Let's look at the following example, where we are going to consider the basic usage of the <datalist> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Datalist</title>
</head>
<body>
<form>
<strong>HTML datalist Tag</strong>
<br>
<input list="values">
<!-- HTML datalist -->
<datalist id="values">
</datalist>
</form>
</body>
</html>
Example : Using value Attribute
Consider the following example, where we are going to use the value attribute along with the <datalist> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Datalist</title>
</head>
<body>
<form>
<strong>HTML datalist Tag</strong>
<br>
<input list="values" name="answer">
<!-- HTML datalist -->
<datalist id="values">
<option value="HTML">HTML</option>
<option value="CSS">CSS</option>
<option value="JavaScript">JavaScript</option>
</datalist>
</form>
</body>
</html>
Example : Using with Date and Time
In the following example, we are going to use the <datalist> tag with the date and time type.
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML datalist tag</title>
</head>
<body>
<!--create a datalist-->
<p>Choose your Time</p>
<input type="time" list="hours">
<datalist id='hours'>
<option value="08:00"></option>
<option value="10:00"></option>
<option value="12:00"></option>
</datalist>
</body>
</html>
Supported Browsers
| Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| button | Yes 20.0 | Yes 10.0 | Yes 4.0 | Yes 12.1 | Yes 9.5 |




