HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML Form Attributes Tutorial

An HTML form is used to collect user input. The form element in HTML has several attributes that can be used to control the behavior of the form. In this tutorial, we will go over some of the most commonly used form attributes and how to use them.

1. action Attribute

The action attribute specifies where the form data should be submitted when the user submits the form. It should be a URL where the form data will be sent to. If the action attribute is not specified, the form data will be submitted to the current page.

<form action="submit_form.php" method="post">
  <!-- form fields go here -->
</form>

2. method Attribute

The method attribute specifies how the form data should be submitted. It can have two values: get or post. The get method appends the form data to the URL, while the post method sends the data in the request body.

<form action="submit_form.php" method="post">
  <!-- form fields go here -->
</form>

3. target Attribute

The target attribute specifies where the response from the form submission should be displayed. It can have values such as _self, _blank, _parent, or _top. If not specified, the response will be displayed in the same window.

<form action="submit_form.php" method="post" target="_blank">
  <!-- form fields go here -->
</form>

4. autocomplete Attribute

The autocomplete attribute specifies whether the browser should autocomplete form fields. It can have values of on or off.

<form action="submit_form.php" method="post" autocomplete="off">
  <!-- form fields go here -->
</form>

5. enctype Attribute

The enctype attribute specifies how the form data should be encoded before it is sent to the server. It is used when the form includes file uploads. The value should be set to multipart/form-data when uploading files.

<form action="submit_form.php" method="post" enctype="multipart/form-data">
  <!-- form fields go here -->
</form>

6. novalidate Attribute

The novalidate attribute specifies that the form should not be validated when submitted. This can be useful when testing a form before it is ready for production.

<form action="submit_form.php" method="post" novalidate>
  <!-- form fields go here -->
</form>
Attribute Description
action Specifies where the form data should be submitted
method Specifies how the form data should be submitted
target Specifies where the response should be displayed
autocomplete Specifies whether form field autocomplete is enabled
enctype Specifies how form data should be encoded for file uploads
novalidate Specifies that the form should not be validated