💡 Tip: Login now to track your course progress and unlock your downloadable certificates instantly!

HTML Form Attributes

HTML <form> elements contain several attributes that define how form data is collected, processed, and submitted. These attributes control important aspects such as where and how the data is sent, how it is encoded, and how the form behaves during submission.

The action Attribute

Specifies the URL or file that will handle the form submission.
When the user clicks the submit button, the form data is sent to this location.

Form Action Attribute
<form action="submit_form.php">
  <input type="text" name="username">
  <input type="submit">
</form>

If the action attribute is omitted, the form submits to the same page it’s currently on.

The method Attribute

Defines the HTTP method used to send form data.
There are two common methods:

  • GET – Data is appended to the URL (visible in the address bar).
  • POST – Data is sent in the request body (not visible in the URL).
Form Method Attribute
<form action="submit_form.php" method="post">
  <input type="text" name="email">
  <input type="submit" value="Submit">
</form>

The target Attribute

Specifies where to display the response after submitting the form.

ValueDescription
_selfDefault. Submits in the same tab.
_blankOpens in a new tab or window.
_parentLoads in the parent frame.
_topLoads in the full body of the window.
Form Target Attribute
<form action="submit_form.php" target="_blank">
  <input type="text" name="query">
  <input type="submit" value="Search">
</form>

The enctype Attribute

Specifies how the form data should be encoded before sending it to the server.
It is mainly used with the POST method.

ValueDescription
application/x-www-form-urlencodedDefault. All characters are encoded.
multipart/form-dataUsed for forms that include file uploads.
text/plainSends data without encoding (rarely used).
Form Enctype Attribute
<form action="upload.php" method="post" enctype="multipart/form-data">
  <input type="file" name="fileUpload">
  <input type="submit" value="Upload">
</form>

The autocomplete Attribute

Enables or disables autocomplete for all input fields inside a form.

Form Autocomplete Attribute
<form autocomplete="off">
  <input type="text" name="name" placeholder="Full name">
  <input type="email" name="email" placeholder="Email address">
  <input type="submit">
</form>

You can also set autocomplete on individual input fields.

The novalidate Attribute

Disables form validation when submitting.
This is useful during testing or when validation is handled via JavaScript.

Form Novalidate Attribute
<form action="submit_form.php" novalidate>
  <input type="email" name="email" placeholder="Enter your email">
  <input type="submit">
</form>

The name Attribute

Assigns a name to the form.
This is often used to reference the form in JavaScript.

Form Name Attribute
<form name="registrationForm">
  <input type="text" name="username">
  <input type="submit">
</form>

The rel Attribute

Defines the relationship between the current document and the target resource when the action points to another URL.

Form Rel Attribute
<form action="https://example.com/submit" rel="external">
  <input type="text" name="data">
  <input type="submit">
</form>

The accept-charset Attribute

Specifies the character encodings the server should expect for submitted form data.

Form accept-charset Attribute
<form action="submit_form.php" accept-charset="UTF-8">
  <input type="text" name="comment">
  <input type="submit">
</form>

Example: Various Form Attributes

Different Form Attributes Example
<form action="register.php" method="post" target="_self"
      enctype="multipart/form-data" autocomplete="on" name="userForm">
  
  <label>Full Name:</label>
  <input type="text" name="fullname" required><br><br>

  <label>Email:</label>
  <input type="email" name="email" required><br><br>

  <label>Profile Picture:</label>
  <input type="file" name="profile_pic"><br><br>

  <label>Message:</label><br>
  <textarea name="message" rows="4" cols="30"></textarea><br><br>

  <input type="submit" value="Submit Form">
</form>

Conclusion

HTML form attributes define how form data is sent and processed.
By understanding and combining attributes like action, method, enctype, and target, developers can control form behavior precisely and build robust user input systems.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend