HTML <input> requiredAttribute
Example
An HTML form with a required field:
<form action="demo-form.php">
Username: <input type="text" name="usrname" required>
<input type="submit">
</form>
Try it yourself »
Browser Support
The numbers in the table indicate the first browser version that supports the attribute.
| Attribute | |||||
|---|---|---|---|---|---|
| required | 5.0 | 10.0 | 4.0 | 5.0 | 9.6 |
Definition and Usage
The required attribute is a boolean attribute.
The required attribute specifies that the input field must be filled out before submitting the form.
Note:The required attribute applies to the following input types: text, search, url, tel, email, password, date pickers, number, checkbox, radio, and file.
Differences between HTML 4.01 and HTML5
The required attribute is new in HTML5.
Differences between HTML and XHTML
In XHTML, attribute minimization is forbidden, and the required attribute must be defined as <input required="required" />.
Syntax
<input required>
HTML <input> Tag Other Extensions