Input Element

The <input> element is a versatile form control for collecting user data. Its type attribute changes what it does — text, email, password, checkbox, radio, number, date, and more.

Web

A single tag can become many different controls just by changing its type. The browser then provides matching keyboards, validation, and pickers (for example, a date picker for type="date").

<input> is a void element, so it has no closing tag. Pair it with a <label> and give it a name so its value is submitted with the form.

Examples

HTML

<input type="text" name="username" placeholder="Your name">
<input type="password" name="pw">
<input type="checkbox" name="agree">

Output:

Renders a text field with placeholder text, a masked password field, and a checkbox.

Learn it in a lesson

See also

Back to the Dictionary