Pr.Pg Next Pg

<FORM> tag tutorials

  • The HTML form element inserts a form in the document.

  • A form, is a method to allow authors to collect information from the visitors, and can provide a set of controls for every need

  • When a visitor reaches the form, he only needs to fill the fields and send the form, usually with a submit button.

  • The sent form is received and processed by a processing agent specified in the value of the action attribute of the form element.

  • <FORM> tag has following attributes;

 

Sr No

Attributes

Descriptions

1

ID

The id attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element in other instances.

2

Class

The class attribute assigns a class name (or a list of class names separated by spaces) to the container element.

It is used together with style sheets and tells the browser the class (or classes) to which the element is associated.

3

style

This attribute is used to define presentational attributes for the containing element, and its value should be composed by style sheets properties.

Although in some cases it can become useful, a better practice is to place presentational attributes in external files, relating them to elements with the class attribute. This way you keep the semantic and presentational parts of your document separated.

 

4

Lang

Specifies the language of an element's content

5

action

Points to a file that acts as processing agent for the form data, This agent will process the information as needed compose an e-mail, save the data into a database, etc.

6

Method

The method attribute establishes how the form's data will be sent to the processing on server side. There are two possible values for this attribute (case-insensitive).

GET: The form's data is added to the URI defined in the action attribute.

POST: The form's data is added to the body of the form and data is not visible in URL bar.

 

Syntax:

<body>

<form attribute = value…>

<input attribute = value..>

….

<input attribute = value..>

………

<form>

Example: HTML program for creating simple login page

Output:
Example: HTML program to create registration form

Output:
Pr.Pg border                                              Next Pg