Skip to content

<form> - The Form Element

Form Container HTML 2.0

The form element creates an interactive container for collecting user input and submitting data to a server. It groups form controls like inputs, buttons, and text areas together.

Result
<form action="url" method="get|post">
<!-- Form controls go here -->
</form>

The action attribute specifies where to send form data, and method determines how to send it.

AttributeDescriptionValues
actionURL where form data is sentURL or empty string
methodHTTP method for submissionget, post, dialog
enctypeHow form data is encodedapplication/x-www-form-urlencoded, multipart/form-data, text/plain
nameName of the formString
targetWhere to display response_self, _blank, _parent, _top
AttributeDescriptionValues
novalidateDisable HTML5 validationBoolean
autocompleteEnable/disable autocompleteon, off
AttributeDescriptionValues
accept-charsetCharacter encodings to useCharacter set
relRelationship between document and linked resourcenoopener, noreferrer, etc.

GET sends data in the URL (suitable for searches):

Result

POST sends data in the request body (suitable for sensitive data):

Result

Use multipart/form-data for file uploads:

Result
Result
Result

Bypass HTML5 validation (use server-side validation instead):

Result

Forms automatically validate before submission:

Result

Use JavaScript to customize validation messages:

Result
Result
Result

Every form control needs an associated label:

<form action="/submit" method="post">
<label for="email">Email Address:</label>
<input type="email" id="email" name="email" required>
</form>

Use <fieldset> and <legend> for logical grouping:

Result
Result

Forms should be fully navigable by keyboard. Use proper HTML elements and avoid custom controls when possible.

BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE3+Full support (limited HTML5 validation in IE9-)

The <form> element has been supported since the earliest browsers. HTML5 validation features require modern browsers.