Chapter 4 introduced forms; this chapter is the full toolbox. Choosing the right type gives you the correct on-screen keyboard on mobile, a native picker, and free format checking — all before you write a line of JavaScript.
Text-like inputs
<input type="text" placeholder="Full name"><input type="email" placeholder="you@email.com"> <!-- email keyboard + check --><input type="tel" placeholder="+91…"> <!-- numeric keypad --><input type="url" placeholder="https://…"><input type="password"><input type="search"><textarea rows="4"></textarea> <!-- multi-line -->
Numbers, dates & ranges
<input type="number" min="16" max="99" step="1"><input type="range" min="0" max="100" value="50"> <!-- a slider --><input type="date"> <!-- native calendar --><input type="time"><input type="datetime-local"><input type="month">
Choices
Radio buttons pick one from a set (same name); checkboxes allow many; select is a dropdown:
<!-- Radio: same name = one choice --><label><input type="radio" name="plan" value="basic"> Basic</label><label><input type="radio" name="plan" value="pro"> Pro</label><!-- Checkbox: independent, many --><label><input type="checkbox" name="tools" value="sql"> SQL</label><!-- Select dropdown --><select name="programme"><option value="">Choose…</option><option value="data">Data Analytics</option></select>
File, colour & more
<input type="file" accept="image/*"> <!-- restrict file types --><input type="file" multiple> <!-- allow several --><input type="color"> <!-- a colour picker --><input type="hidden" name="csrf" value="…"> <!-- sent, not shown -->
Practice
Build a "Book a call" form using at least six different input types: name (text), email, WhatsApp (tel), preferred date (date), a programme dropdown (select), a set of interest checkboxes, and a message (textarea). Try it on a phone to see the keyboards change.
Key takeaways
- 01Text-like: text, email, tel, url, password, search, and <textarea> for multi-line.
- 02Numbers/dates: number (min/max/step), range (slider), date/time/datetime-local — native pickers.
- 03Choices: radio (one, same name), checkbox (many), select (dropdown).
- 04Specialised: file (accept/multiple), color, hidden.
- 05The right type gives the correct mobile keyboard, a native picker and free validation.
