forms

<input>

The single most versatile form control — its behavior is driven by the type attribute (text, email, password, number, checkbox, radio, file, date, range, color, hidden, and more). Use it for every scalar user input; use <textarea> only for multi-line text.

<input type="text" name="q" required>

Common attributes

Attribute Purpose
type Control kind: text, email, password, number, checkbox, radio, file, date, range, color, hidden...
name Key sent to the server on submit
value Default or current value
placeholder Hint shown when empty (not a label)
required Field must be filled to submit
pattern Regex the value must match
min / max / step Bounds for numeric and date types
autocomplete Browser autofill hint (email, current-password, etc.)

Examples

<input type="email" name="email" required autocomplete="email">

Email with validation and autofill

<input type="checkbox" name="agree" id="agree"> <label for="agree">I agree</label>

Checkbox with a linked label

<input type="file" name="avatar" accept="image/*">

File picker restricted to images

<input type="range" name="volume" min="0" max="100" step="1" value="50">

Slider control

Gotcha

placeholder is not a label — always pair inputs with a real

Related tags

← All HTML tags · CSS selectors · HTML entities