<input type="text"> is the default, general-purpose single-line text field — the baseline every other text-like input type builds on.
Syntax
<input type="text" name="fullname" maxlength="100">
Basic Example
<label for="fullname">Full Name</label>
<input type="text" id="fullname" name="fullname" maxlength="100" required>
Browser output: a plain single-line text box; on mobile, it typically brings up the standard alphabetic keyboard.
How It Works
type="text" accepts any character with no built-in format validation at all — unlike email or url, the browser won't reject anything based on shape. Any real validation needs pattern, maxlength/minlength, or server-side checks.
Important Attributes
| Attribute | Purpose |
|---|---|
maxlength / minlength | Character count limits |
pattern | A regex the value must match — see pattern |
placeholder | Hint text — see placeholder |
Real-World Example
<label for="coupon">Coupon Code</label>
<input type="text" id="coupon" name="coupon" maxlength="12" pattern="[A-Z0-9]{4,12}" placeholder="e.g. SAVE20">
A promo code field — plain text, but with a length cap and a pattern restricting it to uppercase letters and digits.
Common Mistakes
- Using
type="text"for data that has a more specific, purpose-built type available (email, phone, URL) — missing free validation and better mobile keyboards - Relying only on
maxlengthfor validation when the actual requirement is about content/format, not just length
Best Practices
- Reserve plain
textfor genuinely free-form text with no more specific type available - Add
maxlengthwhere a real limit exists (like a database column size)
Accessibility Considerations
Same as any input — a correctly associated <label> is essential; type="text" carries no special accessibility behavior of its own beyond that baseline.
SEO Considerations
No direct ranking effect.
Browser & Modern HTML Notes
type="text" is also what browsers fall back to for any unrecognized or unsupported type value, making it the safest possible default.
Mini Practice
- Build a text input for a username, with a
maxlengthof 20. - Identify a field currently using
type="text"that should really use a more specific type instead.