HTML required attribute

required attributes forces the user to enter a value in the input field.


<p>See in the url after submitting, input elements outside the form still belong to form due to 'form' attribute. </p>

 <form action="files/required.php" method="post">
  Name:<input type="text" name="fullname">
  Email: <input type="email" name="user-email" required>
  <input type="submit" name="submit">
Try </>

required attribute values

required attribute is a boolean attribute.

Related Tags

input tags which support this attribute are as follows.


This element allows the user to enter data in the form. This element is used in the form element.

See the above given example.

<select> tag

This element represents different options in the form of drop down list. One option is selected from this list of options.


<select required>

<textarea> tag

textarea element defines multi line resizeable texte area. It supports required attribute.


<textarea value="Essay...." required> </textarea>


Was this article helpful?




Get the newsletter