HTML5 Form Features: New Input Types, required, pattern, min, max, datalist, progress, meter and Built-In Validation
New Input Types
| Type | Gives you |
|---|---|
email | Checks for an email shape and shows the email keyboard on phones |
url | Checks for a web address |
tel | Phone keypad on phones |
number | Numbers only with min, max and step |
range | A slider |
date, time, month | A date or time picker |
color | A color picker |
search | A search box |
Validation Attributes
html
<form>
<label for="name">Name</label>
<input id="name" name="name" required minlength="2" maxlength="40">
<label for="email">Email</label>
<input id="email" name="email" type="email" required>
<label for="age">Age (18 to 65)</label>
<input id="age" name="age" type="number" min="18" max="65" step="1">
<label for="zip">PIN code (6 digits)</label>
<input id="zip" name="zip" pattern="[0-9]{6}" inputmode="numeric" title="Enter exactly 6 digits">
<button>Send</button>
</form>
| Attribute | Rule |
|---|---|
required | The field cannot be empty |
minlength, maxlength | Text length limits |
min, max, step | Number and date limits |
pattern | A regular expression the text must match |
title | Helps explain the pattern rule |
When the form is submitted, the browser blocks it and shows a message on the first field with a problem. No JavaScript is needed.
Server check Browser checks help users but can be bypassed. Always validate again on the server.
Datalist: Suggestions While Typing
html
<label for="browser">Favorite browser</label>
<input id="browser" name="browser" list="browsers">
<datalist id="browsers">
<option value="Chrome">
<option value="Firefox">
<option value="Safari">
<option value="Edge">
</datalist>
Range, Output, Progress and Meter
html
<label for="vol">Volume</label>
<input type="range" id="vol" min="0" max="100" value="40">
<label for="task">Upload</label>
<progress id="task" value="65" max="100">65%</progress>
<label for="disk">Disk used</label>
<meter id="disk" min="0" max="100" low="60" high="85" optimum="30" value="72">72%</meter>
progress shows how far a task has gone. meter shows a value inside a known range, such as disk use.
Style Valid and Invalid Fields
css
input:user-invalid { border-color: #c62828; }
input:user-valid { border-color: #2e7d32; }
input:required { border-left: 4px solid #0b5fff; }
Why user-invalid?
:invalid also matches empty required fields before the person types anything, which looks harsh. :user-invalid waits until the user interacts. It is newer, so check MDN or Can I Use for support and use :invalid as a fallback.
Practice
- Build a signup form with required name, email and a 6 digit PIN code pattern
- Add a datalist of cities
- Add a progress bar showing 40 percent
Conclusion
HTML5 adds input types and validation attributes that check forms in the browser. Pair them with clear labels and always re-check on the server.
Quick Summary: Input types; validation attributes; datalist; range, progress, meter; validation styling.

