HTML Form
HTML form is a section of a document which contains controls such as text fields, password fields, check boxes, radio buttons, submit button, menus etc.
An HTML form facilitates the user to enter data that is to be sent to the server for processing such as name, email address, password, phone number, etc.
Why use HTML Form
HTML forms are required if you want to collect some data from of the site visitor.
For example: If a user want to purchase some items on internet, he/she must fill the form such as shipping address and credit/debit card details so that item can be sent to the given address.
HTML Form Controls
There are different types of form controls that you can use to collect data using HTML form −
- Text Input Controls
- Checkboxes Controls
- Radio Box Controls
- Select Box Controls
- File Select boxes
- Hidden Controls
- Clickable Buttons
- Submit and Reset Button
Hidden Form Controls
Hidden form controls are used to hide data inside the page which later on can be pushed to the server. This control hides inside the code and does not appear on the actual page. For example, following hidden form is being used to keep current page number. When a user will click next page then the value of hidden control will be sent to the web server and there it will decide which page will be displayed next based on the passed current page.
Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes −
Sr.No | Attribute & Description |
---|---|
1 | actionBackend script ready to process your passed data. |
2 | methodMethod to be used to upload data. The most frequently used are GET and POST methods. |
3 | targetSpecify the target window or frame where the result of the script will be displayed. It takes values like _blank, _self, _parent etc. |
4 | enctypeYou can use the enctype attribute to specify how the browser encodes the data before it sends it to the server. Possible values are −application/x-www-form-urlencoded − This is the standard method most forms use in simple scenarios.mutlipart/form-data − This is used when you want to upload binary data in the form of files like image, word file etc. |
Read also: HTML Tags Tutorial : You Must Know In 2021