The <input> element creates an interactive form control. Its look and behavior change with type (text, email, password, checkbox, radio, number, file, submit, and more).
Always pair fields with a <label>, give submitted controls a name, and place them inside a <form> when you need form submission. For multi-line text use <textarea>; for option lists use <select>.
Baseline · Widely available.
Core <input> support is stable across browsers since about July 2015. Some newer types and attributes vary by browser.
Obsolete type.
Do not use type="datetime" (UTC date-time). Prefer datetime-local, or separate date / time fields.
Syntax
HTML Syntax
syntax.html
<input type="text" name="field" id="field">
<input> is a void element (no end tag, no children). Connect a label with for/id, or wrap the input inside the label.
Reference
Attributes
Many attributes exist; these are the ones beginners use most. Exact support depends on type:
type="search" is a text-like field tuned for queries.
type="submit" uses value as the button label.
Avoid type="reset" unless you truly need a wipe-the-form control.
Edge Cases & Pitfalls
Most input bugs come from missing labels, missing name, or the wrong type.
a11y
Placeholder is not a label
Placeholders disappear while typing. Always provide a visible <label>.
submit
No name → not submitted
Fields without name are skipped in normal form encoding (except special button cases).
radio
Shared name for radio groups
Different names create separate groups — users can pick more than one “exclusive” option by mistake.
validation
Client checks are not enough
required, pattern, and type checks help UX — always validate again on the server.
obsolete
Skip type="datetime"
Use datetime-local, date, and/or time instead of the obsolete UTC datetime type.
Compatibility
Browser Support
The <input> element is core HTML everywhere. Basic types are universal; some newer types (week, month, color details) and attributes vary.
✓ Baseline · Widely available
<input>
Widely available since about July 2015 (and much earlier for classic types). Chrome, Firefox, Safari, Edge, and Opera all support form inputs. Check caniuse when you rely on less common types.
98%Core input support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet ExplorerClassic types · limited HTML5
Partial
<input>Widely supported
Bottom line: Safe for everyday forms. Progressive-enhance newer types; always keep usable fallbacks and server-side validation.
Remember
Key Takeaways
Role:<input> builds single-value form controls; type chooses the widget.
Label + name: associate a label, and set name for submission.
Void element: no end tag — configure with attributes only.
Validate twice: browser constraints help users; servers must still check data.
One line: a good <input> has the right type, a real label, and a name.
UA style
Default CSS Settings
Appearance depends heavily on type and the browser’s form controls. A simplified idea for text-like inputs:
default.css
input {
display: inline-block;
font: inherit;
/* widget chrome comes from the user agent */
}
Checkboxes, radios, ranges, and file pickers use different native widgets. Style carefully so focus outlines stay visible for keyboard users.
Frequently Asked Questions
The input element creates a form control so users can enter or choose data — text, email, password, checkboxes, radio buttons, numbers, files, and more — depending on the type attribute.
Yes. input has a start tag only — no end tag and no child content. Configure it with attributes.
If you omit type, the browser uses text — a single-line text field.
Use a label with for matching the input’s id, or wrap the control inside the label. Placeholder is not a substitute for a visible label.
name is the key submitted with the form as a name/value pair. Without name, most controls are not included in form submission.
Usually no. Reset buttons often erase filled forms by accident. Prefer clear, intentional UI for discarding edits.