HTML form tag

HTML <form> tag defines a form that collects the data from the user. There are many other elements (input controls such as checkbox, radio buttons, button etc.) that form the structure of form. The values of those elements are sent to the server for processing.

<p>form attribute in the input element associates it with the form</p>
 <form action="files/formtag.php" method="post">
  Candidate name: <input type="text" name="cname"><br>
  Email: <input type="email" name="cemail"><br>
  Password: <input type="password" name="pass" ><br>
  <input type="submit" name="submit"></p>
 </form>
</>

form attribute in the input element associates it with the form

Candidate name:
Email:
Password:

Tag omission

Both starting and ending tags are necessary for the form element.

Global Attributes

All the global attributes are applicable on the form element.

Tag Attributes

Attributes that are applicable to <form> tag
accept-charset

It represents the character encoding type of the form.

<form action="process.php" accept-charset="UTF-8"> form structure consisting of input elements</form>
action

It represents the HTTP method to submit the data.

<form action="process.php"> form structure consisting of input elements</form>
autocomplete

Input field suggests the user different options for autofill feature.

<form action="process.php" autocomplete> <input type="text" name="fname" /> </form>
enctype

encoding type for the form submission.

<form action="process.php" enctype="text/plain"> form structure with input element.</form>
method

This attribute gives the controls such as play/pause, volume control.

<form action="process.php" method="post"> form structure consisting of input elements</form>
name

specifies a unique name for the form.

<form action="the file name to process the form" name="candidate-data"></form>
novalidate

The form is submitted without validation.

target

represents the browsing mode of form submission.

<form action="" target="_blank"> The data in input controls. </form>


Was this article helpful?

 

Email:

Message: