Forms Lesson 31 of 42
HTML Input Types — Text, Email, Number, Date, Checkbox and More
A tour of HTML input types — text, password, email, number, tel, date, color, range, file, checkbox and radio — with examples and when to use each.
The <input> element is like a multi-tool. By changing its type, it can become a text box, a password field, a date picker, a slider, a color picker or a checkbox. Choosing the right type makes forms easier to fill in — especially on phones, where the right type shows the right keyboard.
Text-like inputs
<form>
<p><label>Name: <input type="text" name="name"></label></p>
<p><label>Password: <input type="password" name="pw"></label></p>
<p><label>Email: <input type="email" name="email"></label></p>
<p><label>Mobile number: <input type="tel" name="mobile" placeholder="0917 123 4567"></label></p>
<p><label>Website: <input type="url" name="site" placeholder="https://"></label></p>
<p><label>Search: <input type="search" name="q"></label></p>
<button>Submit</button>
</form>
| Type | What's special |
|---|---|
text | The default; one line of any text |
password | Hides the characters as dots |
email | Checks for an @ sign; phones show a keyboard with @ |
tel | Phones show a number keypad |
url | Expects a web address; phones show ".com" and "/" keys |
search | A text box styled for searching, often with a clear (×) button |
Numbers and ranges
<form>
<p><label>Age: <input type="number" name="age" min="12" max="20" value="15"></label></p>
<p><label>How much do you like coding? (0–10)
<input type="range" name="like" min="0" max="10" value="7"></label></p>
<button>Submit</button>
</form>
numbergives a box with up/down arrows. Usemin,maxandstepto limit it.rangegives a slider. It's good when the exact number doesn't matter much.
Dates and times
<form>
<p><label>Birthday: <input type="date" name="birthday"></label></p>
<p><label>Pickup time: <input type="time" name="pickup"></label></p>
<p><label>Event start: <input type="datetime-local" name="event"></label></p>
<button>Submit</button>
</form>
Browsers show a calendar or clock picker, so users don't have to type dates in a particular format. That avoids confusion like "is 03/04 March 4 or April 3?"
Checkboxes — choose any number
Use checkboxes when the user can pick zero, one, or many options. Each checkbox needs a value (what's sent when it's checked).
<form>
<p>Which subjects do you enjoy?</p>
<label><input type="checkbox" name="subjects" value="math"> Math</label><br>
<label><input type="checkbox" name="subjects" value="science"> Science</label><br>
<label><input type="checkbox" name="subjects" value="ict" checked> ICT</label><br>
<label><input type="checkbox" name="subjects" value="mapeh"> MAPEH</label><br><br>
<button>Submit</button>
</form>
The checked attribute makes an option checked from the start.
Radio buttons — choose only one
Use radio buttons when the user must pick exactly one option. The trick: all radio buttons in a group must share the same name. That's what makes selecting one unselect the others.
<form>
<p>Preferred learning mode:</p>
<label><input type="radio" name="mode" value="f2f"> Face-to-face</label><br>
<label><input type="radio" name="mode" value="online"> Online</label><br>
<label><input type="radio" name="mode" value="blended"> Blended</label><br><br>
<button>Submit</button>
</form>
Other useful types
<form>
<p><label>Favorite color: <input type="color" name="color" value="#0f5c4d"></label></p>
<p><label>Upload your project: <input type="file" name="project" accept=".html,.zip"></label></p>
</form>
coloropens a color picker.filelets users pick a file to upload.acceptlimits the file types;multipleallows several files.hiddensends a value the user doesn't see (for example, which form version it was).submitandresetcreate buttons, though<button>is more flexible.
Common input attributes
| Attribute | What it does |
|---|---|
value | The starting value |
placeholder | A gray hint shown when empty |
required | Must be filled in before submitting |
readonly | Can be seen and sent but not changed |
disabled | Grayed out, not sent |
autocomplete | Lets the browser fill in saved info (e.g. autocomplete="email") |
min, max, step | Limits for numbers, dates and ranges |
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04