Aral Code

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

Example text, password, email, tel, url, search
<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>
TypeWhat's special
textThe default; one line of any text
passwordHides the characters as dots
emailChecks for an @ sign; phones show a keyboard with @
telPhones show a number keypad
urlExpects a web address; phones show ".com" and "/" keys
searchA text box styled for searching, often with a clear (×) button

Numbers and ranges

Example number and range
<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>
  • number gives a box with up/down arrows. Use min, max and step to limit it.
  • range gives a slider. It's good when the exact number doesn't matter much.

Dates and times

Example date, time, datetime-local
<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).

Example Checkboxes
<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.

Example Radio buttons
<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

Example color and file
<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>
  • color opens a color picker.
  • file lets users pick a file to upload. accept limits the file types; multiple allows several files.
  • hidden sends a value the user doesn't see (for example, which form version it was).
  • submit and reset create buttons, though <button> is more flexible.

Common input attributes

AttributeWhat it does
valueThe starting value
placeholderA gray hint shown when empty
requiredMust be filled in before submitting
readonlyCan be seen and sent but not changed
disabledGrayed out, not sent
autocompleteLets the browser fill in saved info (e.g. autocomplete="email")
min, max, stepLimits for numbers, dates and ranges

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Which input type hides what the user types?
2. A question allows only ONE answer. Which input type fits?
3. What makes radio buttons work as one group?
4. Which type shows a number keypad on phones for a mobile number?
5. Which attribute makes a checkbox checked when the page loads?

By Sir Reyel · Last updated 2026-12-04