What is HTML Form?

In this section we are going to understand the HTML form, which is also know as web form.

What is HTML Form?

What is HTML/Web Form in HTML?

In this tutorial we are going to understand about the HTML form, which is also know as the Web Form. This is used to accept the data from user and then it to server for further processing.

HTML/Web form is an HTML element which takes the user input in text filed, textarea and other such input filelds. This data can be validated on the client browser using the JavaScript. After validation of data when user clicks on the "Submit" button form data is sent to the server for further processing.

HTML Form is used for development of dynamic web applications where user enters the input and based on the user input server sends response to the client. If you are learning web application development then you must learn to use HTML Form.

How to create HTML form?

HTML form is created with the help of <form> </form> tag and within this tag you will have all the input elements for taking user input. Here is an example of HTML Login form:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Login Form</TITLE>
 </HEAD>

 <BODY>
  <form action="login.php" method="post">
	<p>Login Form:</p>
	<p>User Name: <input type="text" name="login"></p>
	<p>Password: <input type="password" name="password"></p>
	<p> <input type="submit" name="submit" value="Login"></p>
  </form>

 </BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE>Login Form</TITLE>
 </HEAD>

 <BODY>
  <form action="login.php" method="post">
	<p>Login Form:</p>
	<p>User Name: <input type="text" name="login"></p>
	<p>Password: <input type="password" name="password"></p>
	<p> <input type="submit" name="submit" value="Login"></p>
  </form>

 </BODY>
</HTML>

Above code creates a login page which will look like:

Form Action

There is property action of the form which is actually the name of server resource which will handle submitted data. In this case login.php is a PHP file which will process the data.

Form Method

There is various ways to send the data to server, post is one of the method/protocol of sending data to server.

From Input filed

The tag <input type="text" name="login"> is used to create the text filed for entering the user name.

Form Password field

The tag <input type="password" name="password"> is use to take input as password from the user on HTML page.

Form Submit button

The tag <input type="submit" name="submit" value="Login"> is used to create Button for submitting the data to client side.

Web Form or HTML form is very flexible and it can have many input fields of different types such as text field, password filed, radio button, combo box etc.

Check tutorial Form and its Elements which provides full details of the elements of a form.

Check more tutorials: