All topics › Unit 2 · Semantic HTML and Forms
Topic 17 · 17 of 43
Input Types and Attributes
All in one: every input type and input attribute, side by side
What this example compares
- Look-alike boxes:
type="text"vs no type vs an unknown type vs"password"vs"search"vs"hidden" - Checked shape:
textvsemailvsemail multiplevsurl - Phone or quantity:
type="tel"vstype="number" - Pickers:
datevstimevsdatetime-localvsmonthvsweek - Colour, slider, exact number:
colorvsrangevsnumber - One or many:
radiowith one sharednamevs radios with different names vscheckbox(withchecked,value,<fieldset>+<legend>) - Labels for a choice:
<label for>+idvs a wrapping<label>vs loose text vstitleonly - Pre-chosen and long lists:
checkedvs<option selected>vs<select multiple>vs the wrong<option checked> - Files:
type="file"vsaccept=".pdf,.jpg"vsaccept="image/*"vsmultiplevs a form withoutenctype - Buttons:
type="submit"vs"reset"vs"button"vs"image"vs<button type="submit"> - Hint or data:
placeholdervsvaluevsrequired - Locked boxes:
readonlyvsdisabled - Limits on the value:
min/maxvsstep="5"vsstep="0.01"vsminon a date - Length and width:
minlengthvsmaxlengthvssize="8"vssize="30" - Helpers:
autofocusvsautocomplete="email"vsautocomplete="off"vslist+<datalist>vspattern+title - All together: the registration snippet of 17.5
Point at any word in the code to see what it means (tap on a phone); click a word to keep its meaning on screen. Read the comment above each numbered panel, press Run, then Edit & experiment to try the TRY lines yourself.
Loading the example…
What you should see
You should see sixteen panels, with panels 2 and 3, 5 and 6, 7 and 8, and 11 and 12 side by side. In panel 1 the password card shows dots, yet its green line sends pw=Asha@123, and the hidden card shows nothing but sends source=web. The email and url cards of panel 2 are red, while the same text in the plain text card is valid. In panel 3 the tel card keeps +91 98765 43210 but the first number card is empty and sends phone=. The pickers send 2026-11-03, 09:30, 2026-11-03T09:30, 2026-11 and 2026-W45. The radios with different names send a=1&b=2&c=3, the checkboxes send skill=html&skill=css, the readonly box sends course=CSE326 and the disabled one sends (nothing). The limits in panel 13 are red except the price, and the registration form of panel 16 is red because age and password are still empty. The Console prints the same line for every form, one per line and named by panel and card (13a = panel 13, card a), and adds a SUBMITTED line each time a form is sent.
Quick check: in panel 12, which attribute would you put on a box so that the user cannot change it, but the server still receives its value?
readonly. disabled also stops editing, but it greys the box out and its value is never sent: compare the two green lines.