HTML & CSSEasy
What are input types?
The type attribute of <input> selects the kind of control and its built-in behavior: text, email, password, number, tel, url, search, date, time, datetime-local, month, week, color, range, checkbox, radio, file, hidden, submit, reset, button and image. Choosing the right type gives free validation, the right mobile keyboard and native pickers.
Text-like
text: default single-line text.email: validates email format; email keyboard on mobile;multiplefor comma-separated lists.password: masked; useautocomplete="current-password"or"new-password"for password managers.tel: phone keypad (no format validation; addpattern).url: validates absolute URLs.search: may show a clear button; pairs with the<search>element.
Numbers and ranges
number: spinner,min/max/step; not suitable for things like card numbers or ZIP codes (usetextwithinputmode="numeric").range: slider for approximate values.
Dates and times
date, time, datetime-local, month, week open native pickers and return ISO strings (2026-11-21).
Choice
checkbox (independent on/off), radio (one of a group sharing a name).
Others
color: color picker returning#rrggbb.file: file chooser;accept="image/*",multiple,captureon mobile.hidden: data sent with the form but not shown.submit,reset,button,image: buttons (prefer<button>elements).
Related attributes
inputmode (keyboard hint without validation), enterkeyhint, autocomplete, pattern, required.
Code example
html
1<style>2 body { font-family: system-ui; }3 form { display: grid; grid-template-columns: max-content 1fr; gap: 8px 12px; max-width: 420px; align-items: center; }4</style>5<form>6 <label for="e">email</label> <input id="e" type="email" autocomplete="email">7 <label for="p">password</label> <input id="p" type="password" autocomplete="new-password" minlength="12">8 <label for="t">tel</label> <input id="t" type="tel" autocomplete="tel">9 <label for="u">url</label> <input id="u" type="url" placeholder="https://">10 <label for="n">number</label> <input id="n" type="number" min="0" max="100" step="5">11 <label for="zip">PIN code</label> <input id="zip" type="text" inputmode="numeric" pattern="[0-9]{6}">12 <label for="r">range</label> <input id="r" type="range" min="0" max="10">13 <label for="d">date</label> <input id="d" type="date" min="2026-01-01">14 <label for="dt">datetime-local</label> <input id="dt" type="datetime-local">15 <label for="c">color</label> <input id="c" type="color" value="#4f46e5">16 <label for="f">file</label> <input id="f" type="file" accept="image/*" multiple>17 <span>checkbox</span> <label><input type="checkbox" checked> Subscribe</label>18 <span>radio</span> <span><label><input type="radio" name="s" checked> S</label> <label><input type="radio" name="s"> M</label></span>19 <input type="hidden" name="source" value="landing">20 <span></span> <button>Submit</button>21</form>
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.