HTML5 Forms & New Input Types
Enhanced inputs, validation attributes and new form elements.
New HTML5 Input Types
| Type | Purpose |
|---|---|
email | Auto-validates email format |
url | Validates URL format |
number | Spinner control with min / max / step |
range | Slider control |
date | Native date picker |
time | Native time picker |
datetime-local | Date + time combined |
month / week | Month / week selector |
search | Clear button on supported browsers |
color | Colour picker widget |
tel | Opens numeric keypad on mobile |
HTML5 Form Enhancements
<!-- Placeholder text -->
<input type="text" placeholder="Your name">
<!-- Pattern validation -->
<input type="text" pattern="[0-9]{5}" title="5 digits">
<!-- Required field -->
<input type="email" required>
<!-- Autocomplete -->
<input type="text" autocomplete="name">
Datalist (Suggestions)
<input list="courses" name="course">
<datalist id="courses">
<option value="HTML">
<option value="CSS">
<option value="JavaScript">
</datalist>
Provides a list of pre-defined options for an <input> — like an autocomplete suggestion box.
Output, Progress & Meter
<input type="range" id="r" value="0"
oninput="o.value = r.value">
<output id="o" for="r">0</output>
<progress value="70" max="100">70%</progress>
<meter value="75" min="0" max="100">75%</meter>
| Element | Purpose |
|---|---|
<output> | Represents the result of a calculation or user interaction — ideal for live form computations. |
<progress> | Displays a progress bar indicating how much of a task has been completed. |
<meter> | Represents a scalar measurement within a known range — disk usage, score, relevance. |
Activity — complete the code
Complete the code correctly to mark this lesson as complete automatically.
Complete the HTML5 form with new input types and elements.
<form><input type="" placeholder="you@example.com"><input type="" name="age" min="1" max="120"><input ="courses" name="course"><datalist id="courses"><option value="HTML"><option value="CSS"></datalist>< value="70" max="100"></progress></form>