Input Types in HTML
? Input Types in HTML
The <input> element supports various type attributes to collect different kinds of user input.
Common Input Types
| Type | Description | Example |
|---|---|---|
text | Single-line text input | <input type="text" name="name"> |
password | Text input masked for passwords | <input type="password"> |
email | For email addresses, with validation | <input type="email"> |
number | Numeric input with optional min/max | <input type="number" min="1" max="10"> |
tel | Telephone number input | <input type="tel"> |
url | URL input with validation | <input type="url"> |
date | Date picker | <input type="date"> |
time | Time picker | <input type="time"> |
checkbox | Checkbox for multiple choices | <input type="checkbox"> |
radio | Radio buttons for single choice | <input type="radio" name="gender"> |
file | File selector for uploading files | <input type="file"> |
submit | Submit button to send the form | <input type="submit" value="Send"> |
reset | Reset button to clear the form | <input type="reset" value="Clear"> |
hidden | Hidden input, not visible to user | <input type="hidden" name="token"> |
color | Color picker | <input type="color"> |
range | Slider to select a value within range | <input type="range" min="0" max="100"> |
Example Form
<form> <input type="text" name="username" placeholder="Username"> <input type="email" name="email" placeholder="Email"> <input type="password" name="password" placeholder="Password"> <input type="date" name="birthdate"> <input type="checkbox" name="subscribe" checked> Subscribe to newsletter <input type="submit" value="Register"></form>Want me to explain specific input types or how to validate input?