Form tag
Advertisements
Form tag
This element is used to create a form on html page. which is a logical grouping of controls available on the page. Form contains controls such as text fields, email field, password fields, checkboxes, button, radio buttons, submit button, menus etc.
Attribute of form tag
- name: are used for provide a name to the form
- action: are used for specify the page to which the data of current page has to be submitted.
- method: are used for specify which method to use for submitting this page to server (get or post).
Why use form tag ?
Form tag are used for get the information from user, for example when you fill the registration form lot of information given by use and these information server get from web page using form element.
Syntax of form tag
Syntax
<form> //input controls e.g. textfield, checkbox, button, radiobutton </form>
Form tag
Tag | Description |
---|---|
<form> | It defines an HTML form to enter inputs by the used side. |
<input> | It defines an input control. |
<textarea> | It defines a multi-line input control. |
<label> | It defines a label for an input element. |
<fieldset> | It groups the related element in a form. |
<legend> | It defines a caption for a <fieldset> element. |
<select> | It defines a drop-down list. |
<optgroup> | It defines a group of related options in a drop-down list. |
<option> | It defines an option in a drop-down list. |
<button> | It defines a clickable button. |
TextField
Example
<html> <head> <form> First Name: <input type="text" name="firstname"/> <br/> Last Name: <input type="text" name="lastname"/> </form> </body> </html>
Result
Password Field
Example
<html> <head> <form> <label for="password">Password: </label> <input type="password" id="password" name="password"/> <form> </body> </html>
Result
Email Field
Example
<html> <head> <form> <label for="email">Email: </label> <input type="email" id="email" name="email"/> <form> </body> </html>
Result
Checkbox
Checkbox are used for select multiple option from list of given options.
Example
<html> <head> <form> Language Known:<br> <input type="checkbox" id="hindi" name="hindi" value="hindi"/> <label for="hindi">HIndi</label> <input type="checkbox" id="english" name="english" value="english"/> <label for="english">English</label> <input type="checkbox" id="french" name="french" value="french"/> <label for="french">French</label> <form> </body> </html>
Result
Radio Button
Example
<html> <head> <form> <label for="gender">Gender: </label> <input type="radio" id="gender" name="gender" value="male"/> Male <input type="radio" id="gender" name="gender" value="female"/> Female <form> </body> </html>
Result
Textarea
<textarea> tag are used for write multiple line text in any input area.
Example
<html> <head> <form> Write below:<br/> <textarea rows="5" cols="40"> </textarea> <form> </body> </html>
Result
Browser supported
Element | |||||
<form> | Yes | Yes | Yes | Yes | Yes |
Google Advertisment