Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
HTML5 Form Input Types
Some of the new input types introduced in HTML5 include:
email url tel number range date time datetime-local month week color <datalist> Element The <datalist> element provides an autocomplete feature on <input> elements. It contains a set of <option> elements that define the available values for the <input>. autocomplete Attribute The autocomplete attribute specifies whether an input field should have autocomplete enabled. Possible values include on and off. Example Form Here is an example form utilizing various HTML5 input types, the <datalist> element, and the autocomplete attribute: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML5 Form Example</title> </head> <body> <h1>HTML5 Form Example</h1> <form action="/submit" method="post"> <!-- Email input --> <label for="email">Email:</label><br> <input type="email" id="email" name="email" autocomplete="on" required><br><br>
<input type="submit" value="Submit"> </form> </body> </html> Explanation: Email, URL, Telephone, Number, Range, Date, Time, and Color Inputs: These input types provide specific functionalities and validation for different kinds of data. Datalist Element: The <datalist> element provides a list of options for the <input> field, creating an autocomplete dropdown. Autocomplete Attribute: The autocomplete attribute is set to on for each input field to enable the browser to provide autofill suggestions. This example demonstrates how to use various HTML5 form input types along with the <datalist> element and the autocomplete attribute to create a more interactive and user- friendly form.