Lesson 36 of 51 · Module 6, lesson 2 of 6 · 3 min
Choosing input types
Pick the right input type so that phones show the right keyboard and the browser can check the answer.
What you'll learn
- The most useful
<input>types- How the right type helps phone users and screen readers
- Checkboxes, and the password field
Why this matters
The type attribute changes how a field behaves. On a phone, type="email" shows a keyboard with @, and type="tel" shows a number pad. Screen readers announce the type. And some types check the input for you. Choosing the right type costs nothing and helps everyone.
The types you will use most
| Type | For | What changes |
|---|---|---|
text | Short text: a name, a city | Nothing special — the default |
email | An email address | Phone keyboard with @; the browser checks the format |
tel | A phone number | Number pad on phones (no format check, because formats differ by country) |
url | A web address | Keyboard with / and .com; checks it starts like an address |
number | A quantity | Number keyboard; arrows to go up and down |
password | A password | Characters hidden as dots |
date | A date | A date picker |
search | A search box | Often a small × to clear it |
checkbox | Yes or no | A box to tick |
A form with several types
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cooking class</title>
</head>
<body>
<h1>Book a cooking class</h1>
<form>
<p>
<label for="email">Email</label>
<input id="email" name="email" type="email">
</p>
<p>
<label for="phone">Phone (with country code)</label>
<input id="phone" name="phone" type="tel">
</p>
<p>
<label for="people">Number of people</label>
<input id="people" name="people" type="number" min="1" max="6" value="1">
</p>
<p>
<label for="day">Preferred day</label>
<input id="day" name="day" type="date">
</p>
<p>
<input id="vegetarian" name="vegetarian" type="checkbox" value="yes">
<label for="vegetarian">I would like vegetarian dishes</label>
</p>
<p>
<button type="submit">Book</button>
</p>
</form>
</body>
</html>
What you'll see: an email box, a phone box, a number box with small arrows, a date box with a calendar icon, a checkbox with its label after it, and a Book button.
Notes on some types
numberacceptsmin,maxandstep. Use it for real quantities only — not for phone numbers, card numbers or postcodes, which are text made of digits.checkbox: the label usually comes after the box. If the box is ticked, the form sendsvegetarian=yes(thevalue). If not, it sends nothing for that field.password: the characters are hidden on screen. That is all — it does not make sending the password safe. (See Where form data goes.)date: the picker looks different in every browser, and the value is always sent asYYYY-MM-DD, such as2026-10-05.
Try it yourself
- Select the example and choose Try it.
- Type
ana(with no @) into the email box and press Book. The browser stops you. - Tick the checkbox, submit, and look for
vegetarian=yesin the message. Untick it and submit again. - Open your own copy on a phone, if you can, and tap each box to see the different keyboards.
Common mistakes
type="text"for everything. Phone users get the wrong keyboard. Fix: pick the matching type.type="number"for a phone number. Leading zeros and+can be lost. Fix:type="tel".- A checkbox without a label, or with plain text next to it. The small box is hard to hit and unnamed for screen readers. Fix: a
<label for>connected to it.
Check yourself
- Which type shows a keyboard with @ on phones?
- Which type should a phone number use?
- What does an unticked checkbox send?
Answers
email.tel.- Nothing.
Next: some answers are a choice from a list, or a long message. The next lesson covers dropdowns, text areas and groups of options.

