**`<input>`** is a single self-closing (void) element that can render dozens of different controls depending on its **`type`** attribute: `text`, `email`, `password`, `checkbox`, `radio`, `date`, `range`, `file`, and more. Its behavior is further refined by attributes like `placeholder` (hint text), `required` (must be filled before submit), `disabled` (not editable/submittable), and `value` (its current or default content).
1Understanding <input>
`<input>` is a single self-closing (void) element that can render dozens of different controls depending on its `type` attribute: text, email, password, checkbox, radio, date, range, file, and more. Its behavior is further refined by attributes like placeholder (hint text), required (must be filled before submit), disabled (not editable/submittable), and value (its current or default content).
Always give an <input> a matching <label> (via the for/id attributes, or by wrapping it) — a placeholder alone disappears once the user starts typing and isn't a reliable substitute for a real label, especially for screen readers.
<label for="email">Email</label>
<input type="email" id="email" name="email" required>2Practical Example
Here is a real-world application of <input> showing how it is used in production HTML.
<!-- Different input types trigger different mobile keyboards and native validation -->
<input type="tel" name="phone" placeholder="555-1234">
<input type="number" name="quantity" min="1" max="10">3Best Practices
Follow these guidelines when working with <input>:
1. Choose the most specific type (email, tel, number, date) instead of always using type="text" — it improves mobile keyboards and built-in validation
2. Pair every input with a proper <label>, not just a placeholder
3. Use the name attribute consistently — it's the key under which the value gets submitted
Tip: Always give an <input> a matching <label> (via the for/id attributes, or by wrapping it) — a placeholder alone disappears once the user starts typing and isn't a reliable substitute for a real label, especially for screen readers.
<label for="email">Email</label>
<input type="email" id="email" name="email" required>