The <input> tag

The <input> tag creates a form field. Its exact behavior depends on the type attribute — text, number, checkbox, file, and more.

Syntax

<input type="text" name="username" value="">

Attributes

type text, email, password, number, checkbox, radio, file, date, tel, and others — determines behavior and built-in validation.
name The key under which the value is submitted with the form data.
value The initial value (or current state for checkbox/radio via checked).
required / pattern / min / max / maxlength Built-in HTML5 validation without any JavaScript.
placeholder A hint shown inside the field that disappears on input. It does NOT replace a label.

Example

<label for="qty">Quantity</label>
<input type="number" id="qty" name="qty" min="1" max="10" value="1">

Notes

  • placeholder is not a substitute for a label — it disappears on focus/input and isn't announced as reliably by screen readers.
  • input is a void element — it has no closing tag.

Accessibility

  • Always associate an input with a label via for/id, not just a placeholder.

Related tools