HTML Form

26 May 2020 | HTML


An Html Form is used when we want to collect data from visitors of a website to the server-side. For example, if a user wants to register on your website, then you would like to collect his information like name, phone no, email address, etc.


A form will collect inputs from the website visitors and then will post it to backend applications such as PHP, ASP, etc.
Html form is create by using <form> Form tag. It contains different types of elements like text fields, check-boxes, radio-buttons, drop-down menu (select-box), label, textarea, submit button, etc.
You can use these elements in your form according to requirements.
The basic structure of an Html form is thusly:

<form action="posturl.php" method = "POST">

   form elements

</form>

 

HTML Form Tags

Sr.No Tag Description
1 <form> The element defines an HTML to collect user input.
2 <label> It is a useful element for a screen-reader that defines a label for an input element.
3 <input> It is the most important form element that defines an input control and allows the user to input.
4 <textarea> It specifies a multi-line input field (a text area) can contain more characters than <input> element.
5 <fieldset> The <fieldset> element is used to group similar data.
6 <legend> The <legend> element is used to define a caption for a <fieldset> element.
7 <select> It is used to define a drop-down list.
8 <option> It is used to define an option that can be selected by the drop-down list.
9 <optgroup> It is used to define a group of related options in a drop-down list.
10 <button> It is used to define a clickable button to submit a form.

 

Form Attributes

Sr.No Attribute Description
1 action It is used to specify the URL of the document where the data will be sent after the form is submitted.
2 method The value of the method attribute of a form element instructs the browser how to submit form data to the server. There are two types of HTTP methods, which are GET and POST.
3 enctype

You can use the enctype attribute to specify how the browser encodes the data before sending it to the server. Possible values are:

(I). application/x-www-form-urlencoded - Default.

(II).  mutlipart/form-data - To load binary data in the form of files such as images, pdf files, etc.

 

HTML Form Example:-

Name

Email

Phone

Gender         Male    Female

Course

      

 

 

 

Buddy! I hope you relished the tutorial, and it was good to see you again. Keep learning. Keep visiting.

Related Blogs