Advertisement
❮ Previous: <footer> Next: <h1> to <h6> ❯

<form>

HTML <form> Tag

Example

<form action="action" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br>
  <input type="submit" value="Submit">
</form>

Try this code ❯

Meaning

<form> element defines a fill-in form that can contain labels and form controls, such as menus and text entry boxes that might be filled in by a user.

Form related elements:

<input>,
<textarea>,
<button>,
<select>,
<option>,
<optgroup>,
<fieldset>,
<label>,
<output>

Version: HTML 2, 3.2, 4, 4.01, 5


Standard Syntax

<form action="URL" method="get|post">
</form>


Advertisement

Attributes

Attribute Value Description
accept fileExtension

audio/*

video/*

image/*

mediaType
Accepts comma-separated content types.
accept-charset characterSet Specifies the list of character encodings for input data that must be accepted by the server processing the form.
action URL action attribute contains the URL of the server program that will process the contents of the form.
autocomplete on

off
autocomplete attribute, will automatically finish filling in information that the user has previously input into an input field.
enctype application/x-www-form-urlencoded

multipart/form-data

text/plain
enctype attribute specifies how form data should be encoded before being sent to the server.

method get

post
method attribute specifies how form information should be transferred to the server using a particular HTTP method.
name text name attribute specifies a name for the form and was traditionally used by JavaScript or other client-side programming technologies to reference forms and their contained elements.
novalidate novalidate novalidate is Boolean attribute determines whether or not form validation should be applied on the elements within.
rel external

help

license

next

nofollow

noopener

noreferrer

opener

prev

search
Specifies the relationship between a linked resource and the current document
target _blank

_self

_parent

_top
target attribute specifies the target frame that will display the results of a form submission.

Deprecated Attributes

Attribute Value Description
accept fileExtension

audio/*

video/*

image/*

mediaType
Accepts comma-separated content types.

Non-Standard Attributes

Attribute Value Description
autocapitalize none

sentences

words

characters
Nonstandard attribute used by iOS Safari that controls how textual form elements should be automatically capitalized.

Global Attributes

<form> element also supports the Global Attributes in HTML.


Event Attributes

<form> element also supports the Event Attributes in HTML.


By Default CSS Value(s)

Most of the browsers will display the <form> element with the following by default value(s)

form {
  display: block;
  margin-top: 0;
}

Related Tags:

<button>,
<datalist>,
<fieldset>,
<form>,
<input>,
<label>,
<legend>,
<meter>,
<optgroup>,
<option>,
<output>,
<progress>,
<select> and
<textarea>

❮ Previous: <footer> Next: <h1> to <h6> ❯
Advertisement