HTML <input> required attribute
Definition and Usage
required
The property specifies that input fields must be filled out before submission.
required
Property is a boolean property.
If the attribute is used, the field is required (or optional).
Note:required
Attributes apply to the following input types:
- text
- search
- url
- tel
- password
- date pickers
- number
- checkbox
- radio
- file
Example
HTML form with a required input field:
<form action="/action_page.php"> <label for="username">Username:</label> <input type="text" id="username" name="username" required> <input type="submit"> </form>
Syntax
<input required>
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
5.0 | 10.0 | 4.0 | 10.1 | 9.6 |
Note:required
Attributes are new attributes in HTML5.