HTML required Attribute


The HTML required attribute is a boolean attribute that, when applied to an <input>, <select>, <textarea>, or other form elements, specifies that the user must fill out that element before submitting the form. It is used to enforce input validation, ensuring that users do not skip important fields. When a form containing an element with the required attribute is submitted, and that element is empty or hasn't been filled out according to other constraints (like type="email" for an email input), the browser automatically displays a message to the user indicating that the field must be filled out. This helps improve the usability of forms by reducing the likelihood of submitting incomplete or incorrect information. Note that while the required attribute is a powerful client-side validation tool, server-side validation is also necessary for security and data integrity.


<tagname required>


The required attribute is a boolean attribute, therefore no values are associated with this attribute.

Applies To

The required attribute can be used on the following html elements.


<form action="formscript.php">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>

Browser Support

The following table will show you the current browser support for the HTML required Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 27th March 2024