Introduction
In this article, I will demonstrate new input types in HTML 5. HTML 5 introduces several input types like Date, DateTime, DateTime-local, time, week, month, email, tel, URL, search, range, color, and number to improve the user experience and to make the forms more interactive. However, if a browser fails to recognize these new input types, it will treat them like a normal text box.
| date | It allows the user to select a date from a drop-down calendar. |
| DateTime | It allows the user to select a date and time along with time zone |
| time | It allows the user to enter time. |
| DateTime-local | It allows the user to select a local date and time |
| week | It allows the user to select a week and year from a drop-down calendar. |
| month | It allows the user to select a month and year from a drop-down calendar. |
| It allows the user to enter an e-mail address. | |
| tel | It allows the user to enter the phone number with a specific pattern. |
| URL | It allows the user to enter a website URL |
| search | It's a text field for entering a search string |
| range | It allows the user to range the value with the slider. |
| number | It allows the user to enter a numeric value with the increase and decrease arrow. |
| color | It allows the user to select a color from the color picker |
Date input type
The date input type in HTML 5 allows the user to select a date from the datepicker calendar. It has got a next button and a pre-button with a closing round button in the center of next and pre. Below is the example of the date input type in HTML 5.
Example of date input type
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h4><span class="text-danger">date</span> input type in html 5</h4>
- <form>
- <div class="form-group">
- <label>Date:</label>
- <input type="date" id="date" class="form-control col-md-3" />
- </div>
- </form>
- </div>
- </body>
- </html>
Output

Datetime
Datetime input type allows the user to select date and time along with time zone but it does not support Internet Explorer, Firefox, Chrome or Opera browsers. It supports only Apple Safari. Below is an example of datetime input type in HTML 5.
Example of datetime input type
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h4><span class="text-danger">datetime</span> input type in html 5</h4>
- <form>
- <div class="form-group">
- <label>Datetime:</label>
- <input type="datetime" id="datetime" class="form-control col-md-3" />
- </div>
- </form>
- </div>
- </body>
- </html>
Output

Datetime-local
Datetime-local input type in HTML 5 allows the user to select date and time. Similar to the datepicker, it has got a next and a pre-button with a closing round button in the center of next and pre, along with AM and PM options. Below is an example of datetime-local input type in HTML 5.
Example of datetime-local input type
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h4><span class="text-danger">datetime-local</span> input type in html 5</h4>
- <form>
- <div class="form-group">
- <label>Datetime-local:</label>
- <input type="datetime-local" id="datetime" class="form-control col-md-3" />
- </div>
- </form>
- </div>
- </body>
- </html>
Output

Time
The time input type in HTML 5 allows the user to enter the time. Below is an example of a time input type.
Example of time input type
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h4><span class="text-danger">time</span> input type in html 5</h4>
- <form>
- <div class="form-group">
- <label>Time:</label>
- <input type="time" id="time" class="form-control col-md-3" />
- </div>
- </form>
- </div>
- </body>
- </html>
Output

Week
Week input type in HTML 5 allows the user to select week and year from the datepicker drop-down. Below is an example of a week's input type.
Example of week input type/span>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container py-5">
- <h4><span class="text-danger">week</span> input type in html 5</h4>
- <form>
- <div class="form-group">
- <label>Week:</label>
- <input type="week" id="week" class="form-control col-md-3" />
- </div>
- </form>
- </div>
- </body>
- </html>
Output










Amir NavedPosted Sep 29, 2019, 12:33 AM
Good Job but need more tags
Abhishek MishraPosted Oct 5, 2018, 4:09 AM
Good one. Nice info
Hardik DeshaniPosted Oct 1, 2018, 11:46 PM
Nice one, Thnx for sharing