HTML · Chapter 37 of 45

HTML Input Types

The <input> tag's type attribute determines what kind of control is rendered and what kind of data it accepts — text, email, password, number, date, checkbox, radio, and many more.

Using the correct semantic input type (like type="email" instead of plain text) provides built-in validation and often triggers better mobile keyboards automatically.

Syntax
<input type="email" name="email">

Common text-like types

type="text" is generic text, type="email" validates email format, type="password" masks characters, and type="number" restricts to numeric input.

Choice-based types

type="checkbox" allows multiple selections, type="radio" allows one choice from a group (grouped by shared name), and type="date" shows a date picker.

Example 1 (html)
<input type="email" name="email" placeholder="you@example.com">
Output
(validates as a proper email format on submit)

type="email" triggers built-in format validation and mobile email keyboards.

Example 2 (html)
<input type="radio" name="plan" value="basic"> Basic
<input type="radio" name="plan" value="pro"> Pro
Output
○ Basic  ○ Pro

Radio buttons sharing the same name allow only one selection at a time.

Key points

  • The type attribute defines the input's behavior and validation.
  • Common types: text, email, password, number, date, checkbox, radio.
  • Semantic types improve validation and mobile keyboard behavior.
  • Radio buttons in the same group must share the same name.
💡 Note: There are over 20 input types in HTML5, including color, range, and search — worth exploring the full list.

📝 Quick Quiz

1. Which input type masks entered characters?

2. What must radio buttons in the same group share?

3. Why use type="email" instead of type="text"?