Common `<input>` attributes include: **`placeholder`** (grey hint text, gone once typing starts), **`required`** (blocks submission if empty), **`disabled`** (not editable and not submitted at all), **`readonly`** (visible and submitted, but not editable by the user), **`min`**/**`max`** (numeric or date range limits), **`minlength`**/**`maxlength`** (text length limits), **`pattern`** (a regular expression the value must match), and **`autofocus`** (focuses the field automatically on page load).
1Understanding INPUT Attributes
Common <input> attributes include: `placeholder` (grey hint text, gone once typing starts), `required` (blocks submission if empty), `disabled` (not editable and not submitted at all), `readonly` (visible and submitted, but not editable by the user), `min`/`max` (numeric or date range limits), `minlength`/`maxlength` (text length limits), `pattern` (a regular expression the value must match), and `autofocus` (focuses the field automatically on page load).
disabled and readonly are easy to confuse: a disabled field is skipped entirely and its value is NOT submitted with the form, while a readonly field's value IS still submitted — it just can't be edited by the user.
<input type="text" name="promo" value="WELCOME10" readonly>
<input type="text" name="notes" disabled>2Practical Example
Here is a real-world application of INPUT Attributes showing how it is used in production HTML.
<!-- Pattern validation: exactly 5 digits -->
<input type="text" name="zip" pattern="[0-9]{5}" title="5-digit ZIP code" required>3Best Practices
Follow these guidelines when working with INPUT Attributes:
1. Use required, pattern, min/max, minlength/maxlength for built-in validation before reaching for JavaScript
2. Choose readonly (not disabled) when a value should still be submitted but not editable, like a pre-filled reference number
3. Use autofocus sparingly — automatically stealing focus can be disorienting, especially on forms with multiple fields
Tip: disabled and readonly are easy to confuse: a disabled field is skipped entirely and its value is NOT submitted with the form, while a readonly field's value IS still submitted — it just can't be edited by the user.
<input type="text" name="promo" value="WELCOME10" readonly>
<input type="text" name="notes" disabled>