Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14
Chapter 4

HTML5 Forms & New Input Types

Enhanced inputs, validation attributes and new form elements.


New HTML5 Input Types

TypePurpose
emailAuto-validates email format
urlValidates URL format
numberSpinner control with min / max / step
rangeSlider control
dateNative date picker
timeNative time picker
datetime-localDate + time combined
month / weekMonth / week selector
searchClear button on supported browsers
colorColour picker widget
telOpens 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>
ElementPurpose
<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>