HTML Form is used to collect data from user and submit it to server for processing data. Html <form> tag is used to collect data from user.
An HTML form contains input controls such as text fields, textarea, password fields, check boxes, radio buttons, submit button, combo box etc.
A submit button sends html form 's data to server.
HTML Form Syntax :
<form action="" method="" enctype="multipart/form-data" name="">
</form>
HTML Form Attributes
Attributes | Description |
action | Set page url to process input data. It is called as form-handler . |
method | Set GET and POST methods. |
target | Specify traget values such as _blank, _self, _parent |
enctype | Specify how the browser encodes the data before it sends it to the server. Enctype values are application/x-www-form-urlencoded and multipart/form-data. multipart/form-data is used to upload files into server. |
name | Specify form name. |
class | Specify class name which is used to apply css style to form. |
onsubmit | It is used to perform action using javascript when submit event is occuered. |
onclick | It is used to perform action using javascript when click event is occuered. |
HTML 5 form control tags
Let's see below HTML 5 control tags which can used to collect data using HTML form.
- Text Input Controls : <input type="text" name="" value="" />
- Checkboxes Controls : <input type="checkbox" name="" value="" />
- Radio Box Controls : <input type="radio" name="" value="" />
- Select Box Controls : <select name=""><option value="">some text</option></select>
- File Select boxes :<input type="file" name="" value="" />
- Hidden Controls : <input type="hidden" name="" value="" />
- Password Controls: <input type="password" name="" value="" />
- Clickable Buttons : <button name="" value=""></button>
- Submit and Reset Button : <input type="submit" name="" value="" />
HTML Tags | Description |
<input> | It is used to define text field, submit button, radio button, password field, email field, color field, hidden field, file field. |
<select> | It is used to define drop-down list. |
<button> | It is used to define clickable button for submitting form. |
<option> | It is used to define value for drop-down list. |
<optgroup> | It is used to define a group of related options in a drop-down list. |
<textarea> | It is used to define multi-line input control. |
Let's see example for html form.
Comments