HTML required Attribute
Description
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.
Syntax
<tagname required>
Values
The required attribute is a boolean attribute, therefore no values are associated with this attribute.
Applies To
Example
Browser Support
The following information will show you the current browser support for the HTML required attribute. Hover over a browser icon to see the version that first introduced support for this HTML attribute.
Browser support for this attribute varies across browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 27th March 2024
