- HTML Tutorial
- HTML - Home
- HTML - Introduction
- 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 - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- 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
- HTML - HEX
- HTML - HSL
- 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 - 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 - 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
HTML <datalist> tag is use to specifies a list of pre-defined options for the <input> element, it provides autocomplete features to an input element, when the user clicks on the input field they will show the dropdown list of pre-defined options. The id attribute of <datalist> tag is equal to the list attribute of an input field. HTML <datalist> element contains a set of <option> elements that represent acceptable or recommended options available to choose from among other controls.
Syntax
<datalist>....</datalist>
Attribute
HTML datalist tag supports Global and Event attributes of HTML.
Examples of HTML datalist Tag
Bellow examples will illustrate the usage of datalist tag, where, when and how to use it to create datalist.
Creatnig HTML Datalist
In the bellow example, we are going to use the datalist tag without input element. It will generate an output displaying nothing on the webpage. because we are using the datalist tag without any option element.
<!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>
Datalist with Value and Text
In this example we are going to use the datalist tag along with the input element like value and text with option element.
<!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>
Datalist with Selected Value
In the following example, we will create a data list where the value will be pre selected. The selected value will be not chnageable to make it chnageable use HTML <select> tag rather than the HTML <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" value="HTML"> <!-- HTML datalist --> <datalist id="values"> <option value="HTML">HTML</option> <option value="CSS">CSS</option> <option value="JavaScript">JavaScript</option> </datalist> </form> </body> </html>
Supported Browsers
Tag | |||||
---|---|---|---|---|---|
button | Yes 20.0 | Yes 10.0 | Yes 4.0 | Yes 12.1 | Yes 9.5 |
To Continue Learning Please Login
Login with Google