HTML Input Attributes
Input elements support attributes that fine-tune behavior: value (default/current content), maxlength (character limit), min/max (numeric or date ranges), and readonly/disabled to control editability.
disabled fields are not submitted with the form and appear greyed out, while readonly fields are submitted but cannot be edited by the user.
<input type="number" min="1" max="10">Limiting input
maxlength restricts the number of characters allowed. min and max set boundaries for number, date, or range inputs.
disabled vs readonly
disabled fields are excluded from form submission entirely and can't be focused. readonly fields are still submitted but the user can't change their value.
<input type="text" maxlength="10" value="Hello">(field pre-filled with 'Hello', max 10 characters)value sets a default and maxlength caps how much more the user can type.
<input type="number" min="1" max="5" value="3">
<input type="text" value="Locked" readonly>(number limited 1-5; text field shown but not editable)min/max bound numeric input; readonly prevents edits but still submits the value.
Key points
- value sets the default/current content of an input.
- maxlength limits how many characters can be entered.
- min and max bound numeric, date, or range values.
- disabled excludes a field from submission; readonly does not.
