Skip to content
Related Articles

Related Articles

HTML | form Tag
  • Difficulty Level : Basic
  • Last Updated : 23 Mar, 2021

Form Tag

Forms are required to take input from the user who visits the website. This form is used basically for the registration process, logging into your profile on a website or to create your profile on a website, etc …The information that is collected from the form is -1. Name 2.Email Addresses etc. Now the form will take input from the form and post that data in backend applications (like PHP). So the backend application will process the data which is received by them.There are various form elements that we can use like text-fields ,text-area ,drop-down list ,select ,checkboxes ,radio etc ..

<form> Form Content... </form>

Attributes: There are many attributes that are associated with the <form> tag. Some of them are listed below: 

  • Action Attribute: -This is used to send the data to the server after the submission of the form.
  • Method: -This is used to upload the data by using two methods that are Get and Post . Get Method: -It has a limited length of characters of URL. -we should not use get to send some sensitive data. -This method is better for nonsecure data. Post Method: -1. It has no size limitations 2. The submission of the form with the method post, can not be bookmarked.
  • Enctype attribute: -This attribute is used to specify that how a browser decodes the data before it sends it to the server .so the values of this attribute are: -1.application/x-www-form-urlencoded − It is the standard method most forms used 2.multipart/form-data -it is used when you have something to upload like files of images, word files, etc.

Example of the form tag:-


<!DOCTYPE html>
   form tag 
   <h1>form tag </h1>
<!--Here we have not used the action attribute as we are not submitting the data to the server-->
   <label for="fname">FirstName</label><!-- Here i have used label to define the label for input -->
   <input type="text" name="fname" placeholder="enter your name" required><!--It defines a text field by using input tag  -->
       <label for="lname">LastName</label>
   <input type="text" name="lname" placeholder="enter your name" required>

The output of the code:- 

Supported Browsers: The browser supported by <form> tag are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up
Recommended Articles
Page :