HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Form Attributes

HTML Forms

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

html

<form action="/samples/form_processor.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

html

<form action="/samples/form_processor.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

html

<form action="/samples/form_processor.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

html

<form action="/samples/form_processor.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

html

<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

html

<form action="/samples/form_processor.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

html

<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

html

<form action="/samples/form_processor.php" 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

html

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

Example: Various Form Attributes

Different Form Attributes Example

html

<form action="/samples/form_processor.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>

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

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.

PreviousHTML Input AttributesNextHTML Form Validation