HTML <form> tag

Usage

Used to declare a user input form. Form data can be entered using various form input types, and then passed to another web page for processing.

Example

Code:

<form action="process.php" method="get">
Username:
<input type="text" name="username" />
<br />
Password:
<input type="password" name="password" />
<br />
<input type="submit" value="Login" />
</form>

Output:

Username:
Password:

Required Attributes

  • action - URL where completed form information should be sent

Optional Attributes

  • accept - a comma separated list of content types that the server can accept
  • accept-charset - a list of possible character sets for the form
  • enctype - the MIME encoding type
  • method - post, get - the method of sending the data to the processing page. Post will be sent as part of the URL, with get it will be sent hidden

Core Attributes