You can place a form anywhere in the body of an HTML document. Some people like to use a table to organize form elements; others create form fields within ordinary paragraphs. A form is enclosed in a two-sided <form> tag:

<form method="post">

The method attribute specifies what will happen when the form is submitted. Almost all forms use the method=”post” attribute, meaning that the data users enter into the form will be collected and either delivered (by e-mail) or sent to the server, where server-side code can retrieve it and perform tasks such as storing it (in a database).

Within the opening <form> tag, you specify an action attribute. This is typically either an e-mail address to which to send information, or the URL of a script that will run when the user submits the form. For an e-mail delivery, the action attribute might look like this:

<form action="" enctype="text/plain">

HTML Forms - The Input Element

An <input> element can vary in many ways, depending on the type attribute. An <input> element can be of type text field, checkbox, password, radio button, submit button, and more.

Text Fields

Example Text Fields

First name:
Last name:

Password Field

<input type="password"> defines a password field:

Example Password Field


Radio Buttons

<input type="radio"> defines a radio button. Radio buttons let a user select ONLY ONE of a limited number of choices:

Example Radio Buttons



<input type="checkbox>" defines a checkbox. Checkboxes let a user select ZERO or MORE options of a limited number of choices.

Example Checkboxes

I have a bike
I have a car

Submit Button

<input type="submit"> defines a submit button.

A submit button is used to send form data to a server. The data is sent to the page specified in the form's action attribute. The file defined in the action attribute usually does something with the received input:

Example Submit Button


HTML Form Tags

<form> Defines an HTML form for user input
<input> Defines an input control
<textarea> Defines a multiline input control (text area)
<label> Defines a label for an <input> element
<fieldset> Groups related elements in a form
<legend> Defines a caption for a <fieldset> element
<select> Defines a drop-down list
<optgroup> Defines a group of related options in a drop-down list
<option> Defines an option in a drop-down list
<button> Defines a clickable button
<datalist> Specifies a list of pre-defined options for input controls
<keygen> Defines a key-pair generator field (for forms)
<output> Defines the result of a calculation