CSS Portal

HTML <form> Tag

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The <form> element in HTML represents a section of a document that contains interactive controls to submit data to a server or process it locally. It acts as a container for various input elements, such as text fields, checkboxes, radio buttons, select menus, and buttons, allowing users to provide information in a structured way. Forms are a fundamental part of web applications, enabling functionalities such as user registration, login, search queries, feedback submission, and e-commerce transactions.

A form provides a structured environment where user inputs can be organized, validated, and sent to a server or handled through client-side scripts. Each form can have a variety of input controls, labels, and grouping elements like <fieldset> and <legend> to enhance accessibility and usability. Forms also facilitate communication between the user interface and server-side processes, often triggering actions when submitted through a button or other control.

The <form> element supports features like input validation, user guidance via placeholder text, and structured grouping of related fields, ensuring that the data collected is accurate and complete. Additionally, forms can be enhanced with JavaScript to provide dynamic behaviors, such as instant validation, interactive feedback, or conditional display of fields.

Properties

Permitted Parents
Any element that accepts flow content
Content
Block, inline, and text, but not containing <form> elements
Start/End Tags
Start tag: required, End tag: required

Example

<form action="" method="post">
First name: <input type="text" name="first_name" /><br />
Last name: <input type="text" name="last_name" /><br />
<input type="submit" value="Submit" />
</form>

Attributes

accept-charset
Specifies a list of character encodings that the server accepts.
action
Specifies a URI/URL of the page that will process the form.
autocomplete
Specifies whether a form should have autocomplete on or off.
enctype
Specifies the content type used to encode the form data set when it's submitted to the server.
Possible values:
  • application/x-www-form-urlencoded (default)
  • multipart/form-data (use this when uploading files)
method
Specifies the HTTP method to use when the form is submitted.
Possible values:
  • get (the form data is appended to the URL when submitted)
  • post (the form data is not appended to the URL)
name
Assigns a name to the form. This is used when referencing the form with stylesheets or scripts. If there are multiple forms, the name of each form must be unique.
novalidate
Specifies that the form should not be validated when submitted.
target
Specifies where to open the action URL.
Possible Values:
  • _blank
  • _parent
  • _self
  • _top

Global Attributes

The <form> tag also supports the Global Attributes in HTML5

Event Attributes

The <form> tag also supports the Event Attributes in HTML5

Browser Support

The following information will show you the current browser support for the HTML <form> tag. Hover over a browser icon to see the version that first introduced support for this HTML tag.

This tag is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 26th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!