# `<input>`

> The `<input>` HTML element creates form controls for user input, like text fields, checkboxes, radio buttons or file uploads, set by the `type` attribute.

## How do I choose the right input type and label it in HTML?

The element that is used to create interactive controls for forms, allowing users to enter data. It supports various types, such as text fields, checkboxes, radio buttons and file uploads, making it a key element in form interactions.

- Topic: Forms
- Type: tag
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 1+, Safari iOS 1+

## Example

Wrong:

```html
<input
  type="text"
  placeholder="Email">
```

Right:

```html
<label for="email">Email</label>
<input
  id="email"
  name="email"
  type="email"
  autocomplete="email"
  required>
```

A real label, `type='email'` and `autocomplete` give a clear name, the right keyboard and autofill.

## Common mistakes

- Using `placeholder` instead of a label, so the hint vanishes while typing.
- Using `type='number'` for phone numbers or postal codes.

## Key points

- Each `<input>` has a linked `<label>`, and `placeholder` is not used as the label.
- The `type` matches the data, like 'email' or 'tel', to get validation and the right mobile keyboard.
- Personal data fields have `autocomplete` values like 'email' or 'given-name'.
- Required fields use the `required` attribute, not only a red asterisk.

## Interview questions

### Should I use type='number' for phone numbers?

No, use `type='tel'`. `number` is for quantities, and it can drop leading zeros and show spin buttons.

### Is a placeholder enough instead of a label?

No, the placeholder disappears while typing and is often low contrast. Use a visible `<label>`.

## Related cards

- [`<label>`](https://wonderium.dev/html/label.md)
- [`<form>`](https://wonderium.dev/html/form.md)
- [Accessible Forms](https://wonderium.dev/a11y/accessible-forms.md)
- [:user-invalid](https://wonderium.dev/css/user-invalid.md)
- [`<datalist>`](https://wonderium.dev/html/datalist.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/input
- Last updated: 2026-11-25
