Forms in HTML
- Form is the most common way for a user to communicate the information from a web browser to server.
- <form> tag is used to create a HTML form. This tag has several attributes and important among them are "method" and "action".
- action: This attribute specifies the URL of the application, which is to be called when the user clicks the submit button (or) submitting the form.
- method: This attribute specifies how the entered data in form is sent to destination. There are two methods of sending information, one is "post" and other is "get".
| Post Method | Get Method |
|---|---|
| Information sent along with body | Information sent along with URL |
| Data is invisible while sending | Data is visible in site address |
| It provides security | No Security |
| It can send any number of characters | It sends limited characters |
- An HTML form is a section of a document which contains controls such as text fields, password fields, checkboxes, radio buttons, submit button, menus etc.
- An HTML form facilitates the user to enter data that is to be sent to the server for processing.
- HTML forms are required if you want to collect some data from of the site visitor.
User Interface elements in Forms:
Label:
This is used to display the text on the screen
format:
Some Text Text Field:
It is an rectangular box.It is used to take the input from the user.This can be created using <input> tag.
format:
Button:
HTML supports three types of buttons,those are
- Button creates a simple button.
format:
- Submit button creates a button and it invokes the form action i.e submits the form.
format:
- Reset button creates a button and it clears the entites,which are entered by user in the form.
format:
- Button creates a simple button.
-
Password Field:
It is an rectangular box.It is used to enter the password.i.e it doesn't display charcters instead of those characters diaplay symbols.
format:
-
Radio Button:
This is used to select only one value at a time.
format:
text -
Checkbox:
This is used to select multiple values at a time.
format:
text -
Combo Box:
It is used to select one value from multiple values.
format:
-
List Box:
It is used to select one (or) more values from multiple values.
format:
-
Text Area:
This is just like a text field but it has multiple rows and columns.
format:
Example : "Lform.html"
login
Output:
Example : "RegistrationForm.html"
Registration- Form
Output: