What is form in html and how to use it?

Form gives us option to enter information like- text fields, textarea fields, drop down boxes, radio button, checkboxes etc. in a form.

Form defined as::
<form>
elements
</form>

Form collect the user information and it contain the elements.
In the form we have various kind if <input>types are::

text  = it defines the text input.
Submit = for submitting the form.
radio = for choose any one option, it is a radio button.
checkbox = for choose multiple option.

For example::

<form>
  First name:<br>
  <input type="text" name="firstname"><br>
  Last name:<br>
  <input type="text" name="lastname"><br><br>
  <input type="submit" value="Submit">
</form>

OUTPUT::


First name:

Last name:






For radio button::
<form>
  <input type="radio" name="gender" value="male"> Male<br>
  <input type="radio" name="gender" value="female"> Female<br>
</form>

OUTPUT::
 Male
 Female



For checkboxes::
<form>
  <input type="checkbox" name="chec" value="dancing"> dancing<br>
  <input type="checkbox" name="chec" value="cricket"> cricket<br>
</form>

OUTPUT::
cricket
dancing

Post a Comment

Previous Post Next Post