HTML <form> Tag

Example

A simple HTML form with two input fields and one submit button:

<form action="form_action.html" method="get">
  First name: <input type="text" name="fname" /><br />
  Last name: <input type="text" name="lname" /><br />
  <input type="submit" value="Submit" />
</form>
Code it Online »

Definition and Usage

The <form> tag is used to create an HTML form for user input.

A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select menus, textarea, fieldset, legend, and label elements.

Forms are used to pass data to a server.

Browser Support

The <form> tag is supported in all major browsers.

Tips and Notes

Note: The form element is a block-level element, and creates a line break before and after itself.

Required Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
action URL Specifies where to send the form-data when a form is submitted STF
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!