HTML Input Types
One tag — input — many behaviors. The type attribute chooses the control style and hints the expected value.
Direct answer
Set type to values such as text, email, password, number, checkbox, radio, date, file, hidden, or submit. Pair every visible input with a label. Browsers may show specialized keyboards on phones for email and number.
📊 Starter input types
| type | Use |
|---|---|
| text | General single-line text |
| Email addresses | |
| password | Masked secrets |
| number | Numeric values |
| checkbox | On/off options (many can be checked) |
| radio | Pick one from a named group |
| date | Calendar date |
| file | Upload a file |
| submit | Submit button-style input (or prefer button) |
Several input types
html<form action="/join" method="post">
<label for="mail">Email</label>
<input id="mail" name="mail" type="email">
<label for="pw">Password</label>
<input id="pw" name="pw" type="password">
<label><input type="checkbox" name="news" value="yes"> Newsletter</label>
<label><input type="radio" name="plan" value="free"> Free</label>
<label><input type="radio" name="plan" value="pro"> Pro</label>
<button type="submit">Join</button>
</form>
Try it
- Build a form with email + password
- Add a checkbox and a two-option radio group sharing one
name - Submit locally and observe which values are intended
- Try
type="number"for an age field
Easy mistakes
- Radio buttons with different
namevalues when they should be one group - Using
textfor passwords - Forgetting labels on checkboxes/radios
Summary
typeselects the input behavior- Match type to the data
- Radios share a name; checkboxes can stand alone
- Always label visible inputs
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top