HTML form tag

In this tutorial you will start learning about the HTML form tags. Before you can learn any of the input tags which HTML provides you with, it is important to learn the <form> tag first. All the HTML input tags depend on the <form> tag for their working. Just like the <html> tag marks the start and end of the webpage, the <form> tag marks the start and end of a form inside the webpage. None of the input tags which you will learn in HTML should be used outside the <form> tag.

The role of the form is not just to collect the information from the user but also submit it back to the server for processing.The processing of the information entered into the form by the user is not the responsibility of HTML; some programming language like Javascript, PHP, asp.net, JSP etc. have to be used for this purpose. HTML only helps in collecting the information using input tags and then submitting it to the server.

The <form> tag has two important attributes without which it will make no sense to use the <form> tag in a webpage. These attributes are

  1. action – This attribute is used to set the URL at which the data entered by the user will be submitted.
  2. method – This attribute is used to tell the way in which the data should be submitted to the server.

There are mainly two values you can set for the method attribute

  1. GET – As the name tells, it is used to get a webpage from the server
  2. POST – As the name tells, it is used to post or send the data to the server

As of now understanding the GET or POST methods is not very important for you. You will find the need to understand about these two methods of submitting the data to the server when you start learning any server side programming language. For now we will just keep our focus on the <form> tag and other input tags which you can use inside the <form> tag.

Syntax for using the <form> tag

To be able to understand how to use a <form> tag inside a webpage, look at the sample code below.

<html>            
    <head>            
    </head>            

    <body>                
        <form action="http://abc.com/index.php" method="GET"> 
             <!-- All the HTML input tags should be used here -->                         
        </form>            
    </body>    
</html>

The form tag has no visual representation inside the browser. This means that like images, paragraphs, list etc. you will not be able to look at the browser and tell if there is any HTML form present on the webpage or not.

We have set the action attribute of the form tag to http://abc.com/index.php and the method attribute is set to GET. The action attribute tells the form tag to go and submit the data entered by the user to the URL http://abc.com/index.php . At this URL some PHP code will be written which will use the submitted data and do some processing on it.

Need Learning Guidence?
Join our Study Groups and get step by step guidence.
Learn HTML and CSS
The goal of creating this study group is to help students who are beginners to HTML and CSS program
7
Members
1
Questions Asked
0
Tasks Added
Learn Website Development
This goal of this study group is to help students learn the basics of website development using HTM
1
Members
0
Questions Asked
0
Tasks Added
Website Development Interview Preparation
This goal of this study group is to help students prepare for their website development interviews.
1
Members
0
Questions Asked
0
Tasks Added
Web Wars 1.0 - Build Your Digital CV
The goal of this study group is to manage all the communication for the 'Web Wars 1.0 - Build Your
110
Members
0
Questions Asked
0
Tasks Added

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp