The required attribute

required makes filling in a field mandatory — the browser blocks form submission and shows a built-in message if the field is empty.

Applies to

input, select, textarea

Values

A boolean attribute: its mere presence enables the check (no value needed).

Example

<input type="email" name="email" required>

Edge cases

  • required is only checked when the form is submitted, not in real time — for instant feedback you need JS or the CSS :invalid selector.
  • novalidate on the <form> itself completely disables required and other built-in validation.

Accessibility

  • Mark required fields visually too (e.g. an asterisk in the label) rather than relying solely on browser behavior, which isn't always obvious.

Related tools