html tutorial - required Attribute in HTML - html5 - html code - html form

Required attribute in html

Learn html - html tutorial - Required attribute in html - html examples - html programs

  • The required attribute is used to specify the input is required and that should not be blank during the form submission.
  • This is a Boolean attribute.

Syntax for required attribute in HTML:

<element required>

Difference between HTML4.01 and HTML 5:

HTML 4.01:

  • HTML4 does not support the required attribute.


  • The required attribute is new to HTML5.

Applies to:

Element Attribute
<input> required
<textarea> required
<select> required

Sample coding for required attribute in HTML:

Tryit<!DOCTYPE html>
        <title>Wikitechy required attribute</title>
            <input type="text" name="username" required>
            <input type="submit">

Code Explanation for required attribute in HTML:

required Attribute Code Explanation

  1. This required attribute used to specifies that the input should be filled during the form submission.

Sample Output for required attribute in HTML:

required Attribute Output part-1

  1. Click the submit button with the blank textbox.
  2. required Attribute Output part-2 submit the form browser shows warning message

  3. When the user try to submit the form the browser shows the warning message.

Browser Support for required attribute in HTML :

5.0 10.0 4.0 No 9.6

Related Searches to required Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.