HTML: input required

The required attribute tells the browser that an input must have a value before the form can be submitted.

What you will learn

Minimal example

<label for="name">Name</label>
<input id="name" name="name" required>
<button type="submit">Send</button>

If the field is empty, the browser normally stops submission and asks the user to fill it in. The visible label explains what value is expected.

Required does not validate everything

required checks that a value is present. Use an appropriate type, pattern, minlength, or other constraint when the format also matters.

Common mistakes