Text Input Types: text, email, tel, url
You'll learn how different input types help browsers collect and validate specific kinds of information automatically.
What Are Input Types?
When creating forms (which you learned about with the <form> element), you use <input> elements to let users type information. HTML provides different type attributes that tell the browser what kind of data you're expecting. This triggers helpful features like custom keyboards on mobile devices and basic validation before the form is even submitted.
The Four Basic Text Input Types
type="text"
The default, all-purpose text input. Accepts any characters:
<input type="text" name="username">
type="email"
For email addresses. Browsers check for basic email format (something@something.something):
<input type="email" name="user-email">
On mobile, this shows a keyboard with easy access to @ and .com.
type="tel"
For telephone numbers. Browsers don't validate format (since phone numbers vary globally), but mobile devices show a numeric keypad:
<input type="tel" name="phone">
type="url"
For web addresses. Browsers check for a valid URL format (starting with http:// or https://):
<input type="url" name="website">
Mobile keyboards make entering :// and .com easier.
Why This Matters
Think of these types like specialized mailboxes: a regular mailbox accepts anything, but specialized ones help sort mail correctly from the start. Using the right input type improves user experience (easier typing) and catches simple mistakes before submission.
Key Takeaway: Different input types like text, email, tel, and url provide built-in browser validation and optimized mobile keyboards, making forms more user-friendly with minimal effort.