VOOZH about

URL: https://www.geeksforgeeks.org/html/html-required-attribute/

⇱ HTML required Attribute - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML required Attribute

Last Updated : 11 Jul, 2025

It is a Boolean attribute that is used to specify that the input element must be filled out before submitting the Form.

Elements: These attributes can be associated with three elements which are listed below:  

Syntax:

<input required>

Example-1: In this example, we demonstrate the use of the required attribute in a form. The attribute ensures that the "Username" field must be filled out before submitting the form.

Output:

👁 Image

Syntax:

<select required>

Example-2: In this example we demonstrates the required attribute in a <select> field. It ensures users select an option other than "None" before submitting the form, styled with green italic headings.

Output:

👁 Image

Syntax:

<textarea required>

Example-3: In this example we demonstrates the required attribute in a <textarea> field, ensuring users provide input before form submission. The page includes green, italic headings and a centered layout.

Output:

👁 Image

Supported Browsers: The browser supported by required attribute are listed below: 

Comment