summaryrefslogtreecommitdiff
path: root/devdocs/html/element%2Fform.html
blob: 73813bd6e0137e2eeca2d696578904399fe956ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<header><h1>&lt;form&gt;: The Form element</h1></header><div class="section-content"><p>The <code>&lt;form&gt;</code> <a href="../index">HTML</a> element represents a document section containing interactive controls for submitting information.</p></div>
<h2 id="try_it">Try it</h2>
<div class="section-content">
<iframe class="interactive is-tabbed-standard-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/form.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe> <p>It is possible to use the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:valid"><code>:valid</code></a> and <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid"><code>:invalid</code></a> CSS <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes">pseudo-classes</a> to style a <code>&lt;form&gt;</code> element based on whether the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements"><code>elements</code></a> inside the form are valid.</p>
</div>
<h2 id="attributes">Attributes</h2>
<div class="section-content">
<p>This element includes the <a href="../global_attributes">global attributes</a>.</p> <dl> <dt id="accept">
<a href="#accept"><code>accept</code></a> <abbr class="icon icon-deprecated" title="Deprecated. Not for use in new websites."> <span class="visually-hidden">Deprecated</span> </abbr>
</dt> <dd> <p>Comma-separated <a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type">content types</a> the server accepts.</p> <div class="notecard note" id="sect1"> <p><strong>Note:</strong> <strong>This attribute has been deprecated and should not be used.</strong> Instead, use the <a href="input#accept"><code>accept</code></a> attribute on <code>&lt;input type=file&gt;</code> elements.</p> </div> </dd> <dt id="accept-charset"><a href="#accept-charset"><code>accept-charset</code></a></dt> <dd> <p> Space-separated <a href="https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding">character encodings</a> the server accepts. The browser uses them in the order in which they are listed. The default value means <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding">the same encoding as the page</a>. (In previous versions of HTML, character encodings could also be delimited by commas.) </p> </dd> <dt id="autocapitalize">
<a href="#autocapitalize"><code>autocapitalize</code></a> <abbr class="icon icon-nonstandard" title="Non-standard. Check cross-browser support before using."> <span class="visually-hidden">Non-standard</span> </abbr>
</dt> <dd> <p>A nonstandard attribute used by iOS Safari that controls how textual form elements should be automatically capitalized. <code>autocapitalize</code> attributes on a form elements override it on <code>&lt;form&gt;</code>. Possible values:</p> <ul> <li>
<code>none</code>: No automatic capitalization.</li> <li>
<code>sentences</code> (default): Capitalize the first letter of each sentence.</li> <li>
<code>words</code>: Capitalize the first letter of each word.</li> <li>
<code>characters</code>: Capitalize all characters — that is, uppercase.</li> </ul> </dd> <dt id="autocomplete"><a href="#autocomplete"><code>autocomplete</code></a></dt> <dd> <p>Indicates whether input elements can by default have their values automatically completed by the browser. <code>autocomplete</code> attributes on form elements override it on <code>&lt;form&gt;</code>. Possible values:</p> <ul> <li>
<code>off</code>: The browser may not automatically complete entries. (Browsers tend to ignore this for suspected login forms; see <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion#the_autocomplete_attribute_and_login_fields">The autocomplete attribute and login fields</a>.)</li> <li>
<code>on</code>: The browser may automatically complete entries.</li> </ul> </dd> <dt id="name"><a href="#name"><code>name</code></a></dt> <dd> <p>The name of the form. The value must not be the empty string, and must be unique among the <code>form</code> elements in the forms collection that it is in, if any.</p> </dd> <dt id="rel"><a href="#rel"><code>rel</code></a></dt> <dd> <p>Controls the annotations and what kinds of links the form creates. Annotations include <a href="../attributes/rel#external"><code>external</code></a>, <a href="../attributes/rel#nofollow"><code>nofollow</code></a>, <a href="../attributes/rel#opener"><code>opener</code></a>, <a href="../attributes/rel#noopener"><code>noopener</code></a>, and <a href="../attributes/rel#noreferrer"><code>noreferrer</code></a>. Link types include <a href="../attributes/rel#help"><code>help</code></a>, <a href="../attributes/rel#prev"><code>prev</code></a>, <a href="../attributes/rel#next"><code>next</code></a>, <a href="../attributes/rel#search"><code>search</code></a>, and <a href="../attributes/rel#license"><code>license</code></a>. The <a href="../attributes/rel"><code>rel</code></a> value is a space-separated list of these enumerated values.</p> </dd> </dl>
</div>
<h3 id="attributes_for_form_submission">Attributes for form submission</h3>
<div class="section-content">
<p>The following attributes control behavior during form submission.</p> <dl> <dt id="action"><a href="#action"><code>action</code></a></dt> <dd> <p>The URL that processes the form submission. This value can be overridden by a <a href="button#formaction"><code>formaction</code></a> attribute on a <a href="button"><code>&lt;button&gt;</code></a>, <a href="input/submit"><code>&lt;input type="submit"&gt;</code></a>, or <a href="input/image"><code>&lt;input type="image"&gt;</code></a> element. This attribute is ignored when <code>method="dialog"</code> is set.</p> </dd> <dt id="enctype"><a href="#enctype"><code>enctype</code></a></dt> <dd> <p>If the value of the <code>method</code> attribute is <code>post</code>, <code>enctype</code> is the <a href="https://en.wikipedia.org/wiki/Mime_type" target="_blank">MIME type</a> of the form submission. Possible values:</p> <ul> <li>
<code>application/x-www-form-urlencoded</code>: The default value.</li> <li>
<code>multipart/form-data</code>: Use this if the form contains <a href="input"><code>&lt;input&gt;</code></a> elements with <code>type=file</code>.</li> <li>
<code>text/plain</code>: Useful for debugging purposes.</li> </ul> <p>This value can be overridden by <a href="button#formenctype"><code>formenctype</code></a> attributes on <a href="button"><code>&lt;button&gt;</code></a>, <a href="input/submit"><code>&lt;input type="submit"&gt;</code></a>, or <a href="input/image"><code>&lt;input type="image"&gt;</code></a> elements.</p> </dd> <dt id="method"><a href="#method"><code>method</code></a></dt> <dd> <p> The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP">HTTP</a> method to submit the form with. The only allowed methods/values are (case insensitive): </p> <ul> <li>
<code>post</code>: The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST"><code>POST</code></a> method; form data sent as the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Request/body">request body</a>.</li> <li>
<code>get</code> (default): The <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET"><code>GET</code></a>; form data appended to the <code>action</code> URL with a <code>?</code> separator. Use this method when the form <a href="https://developer.mozilla.org/en-US/docs/Glossary/Idempotent">has no side effects</a>.</li> <li>
<code>dialog</code>: When the form is inside a <a href="dialog"><code>&lt;dialog&gt;</code></a>, closes the dialog and causes a <code>submit</code> event to be fired on submission, without submitting data or clearing the form.</li> </ul> <p>This value is overridden by <a href="button#formmethod"><code>formmethod</code></a> attributes on <a href="button"><code>&lt;button&gt;</code></a>, <a href="input/submit"><code>&lt;input type="submit"&gt;</code></a>, or <a href="input/image"><code>&lt;input type="image"&gt;</code></a> elements.</p> </dd> <dt id="novalidate"><a href="#novalidate"><code>novalidate</code></a></dt> <dd> <p>This Boolean attribute indicates that the form shouldn't be validated when submitted. If this attribute is not set (and therefore the form <strong><em>is</em></strong> validated), it can be overridden by a <a href="button#formnovalidate"><code>formnovalidate</code></a> attribute on a <a href="button"><code>&lt;button&gt;</code></a>, <a href="input/submit"><code>&lt;input type="submit"&gt;</code></a>, or <a href="input/image"><code>&lt;input type="image"&gt;</code></a> element belonging to the form.</p> </dd> <dt id="target"><a href="#target"><code>target</code></a></dt> <dd> <p>Indicates where to display the response after submitting the form. It is a name/keyword for a <em>browsing context</em> (for example, tab, window, or iframe). The following keywords have special meanings:</p> <ul> <li>
<code>_self</code> (default): Load into the same browsing context as the current one.</li> <li>
<code>_blank</code>: Load into a new unnamed browsing context. This provides the same behavior as setting <a href="#rel"><code>rel="noopener"</code></a> which does not set <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/opener"><code>window.opener</code></a>.</li> <li>
<code>_parent</code>: Load into the parent browsing context of the current one. If no parent, behaves the same as <code>_self</code>.</li> <li>
<code>_top</code>: Load into the top-level browsing context (i.e., the browsing context that is an ancestor of the current one and has no parent). If no parent, behaves the same as <code>_self</code>.</li> </ul> <p>This value can be overridden by a <a href="button#formtarget"><code>formtarget</code></a> attribute on a <a href="button"><code>&lt;button&gt;</code></a>, <a href="input/submit"><code>&lt;input type="submit"&gt;</code></a>, or <a href="input/image"><code>&lt;input type="image"&gt;</code></a> element.</p> </dd> </dl>
</div>
<h2 id="examples">Examples</h2>
<div class="section-content"><div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="sgoC2PpCpEoHvF8uA7Pgbk3UfBmveJzLc6BlFK7Dqzo=" data-language="html"><span class="token comment">&lt;!-- Form which will send a GET request to the current URL --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span> <span class="token attr-name">method</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>get<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span>
    Name:
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>submitted-name<span class="token punctuation">"</span></span> <span class="token attr-name">autocomplete</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span><span class="token punctuation">&gt;</span></span>Save<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- Form which will send a POST request to the current URL --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span> <span class="token attr-name">method</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>post<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span>
    Name:
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>submitted-name<span class="token punctuation">"</span></span> <span class="token attr-name">autocomplete</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>name<span class="token punctuation">"</span></span> <span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span><span class="token punctuation">&gt;</span></span>Save<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>

<span class="token comment">&lt;!-- Form with fieldset, legend, and label --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>form</span> <span class="token attr-name">method</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>post<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>fieldset</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>legend</span><span class="token punctuation">&gt;</span></span>Do you agree to the terms?<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>legend</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>yes<span class="token punctuation">"</span></span> <span class="token punctuation">/&gt;</span></span> Yes<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>label</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>radio<span class="token punctuation">"</span></span> <span class="token attr-name">value</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>no<span class="token punctuation">"</span></span> <span class="token punctuation">/&gt;</span></span> No<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>label</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>fieldset</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>form</span><span class="token punctuation">&gt;</span></span>
</pre>
</div></div>
<h3 id="result">Result</h3>
<div class="section-content"><div class="code-example" id="sect2">

<iframe class="sample-code-frame" title="Examples sample" id="frame_examples" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/form/runner.html?id=examples" loading="lazy"></iframe>
</div></div>
<h2 id="technical_summary">Technical summary</h2>
<div class="section-content"><figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td> <a href="../content_categories#flow_content">Flow content</a>, <a href="../content_categories#palpable_content">palpable content</a> </td> </tr> <tr> <th scope="row">Permitted content</th> <td>
<a href="../content_categories#flow_content">Flow content</a>, but not containing <code>&lt;form&gt;</code> elements</td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="../content_categories#flow_content">flow content</a> </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/form_role">form</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td> <code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/search_role">search</a></code>, <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/none_role"><code>none</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/presentation_role"><code>presentation</code></a> </td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement"><code>HTMLFormElement</code></a></td> </tr> </tbody> </table></div></figure></div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/forms.html#the-form-element">HTML Standard <br><small># the-form-element</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody>
<tr>
<th><code>form</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>accept</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>accept-charset</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>action</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">≤4</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">≤3.2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>autocapitalize</code></th>
<td class="bc-supports-yes">43</td>
<td class="bc-supports-yes">79</td>
<td class="bc-supports-yes">111</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">30</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">43</td>
<td class="bc-supports-yes">43</td>
<td class="bc-supports-yes">111</td>
<td class="bc-supports-yes">30</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">4.0</td>
</tr>
<tr>
<th><code>autocomplete</code></th>
<td class="bc-supports-yes"><details><summary>14</summary>The Google Chrome UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Chrome might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes"><details><summary>15</summary>The Opera UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Opera might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
<td class="bc-supports-yes">6</td>
<td class="bc-supports-yes"><details><summary>4.4</summary>The Google Chrome UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Chrome might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
<td class="bc-supports-yes"><details><summary>18</summary>The Google Chrome UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Chrome might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes"><details><summary>14</summary>The Opera UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Opera might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
<td class="bc-supports-yes">6</td>
<td class="bc-supports-yes"><details><summary>1.0</summary>The Samsung Internet UI for auto-complete request varies, depending on whether <code>autocomplete</code> is set to <code>off</code> on <code>&lt;input&gt;</code> elements as well as their form. Specifically, when a form has <code>autocomplete</code> set to <code>off</code> and its <code>&lt;input&gt;</code> element's <code>autocomplete</code> attribute is not set, then if the user asks for autofill suggestions for the <code>&lt;input&gt;</code> element, Samsung Internet might display a message saying 'autocomplete has been disabled for this form.' On the other hand, if both the form and the input element have <code>autocomplete</code> set to <code>off</code>, the browser will not display that message. For this reason, you should set <code>autocomplete</code> to <code>off</code> for each <code>&lt;input&gt;</code> that has custom auto-completion.</details></td>
</tr>
<tr>
<th><code>enctype</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>method</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>name</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>novalidate</code></th>
<td class="bc-supports-yes">10</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">10</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">10.1</td>
<td class="bc-supports-yes">37</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">10.3</td>
<td class="bc-supports-yes">1.0</td>
</tr>
<tr>
<th><code>rel</code></th>
<td class="bc-supports-yes">108</td>
<td class="bc-supports-yes">108</td>
<td class="bc-supports-yes">111</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">94</td>
<td class="bc-supports-yes">15.4</td>
<td class="bc-supports-yes">108</td>
<td class="bc-supports-yes">108</td>
<td class="bc-supports-yes">111</td>
<td class="bc-supports-yes">73</td>
<td class="bc-supports-yes">15.4</td>
<td class="bc-supports-yes">21.0</td>
</tr>
<tr>
<th><code>target</code></th>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">12</td>
<td class="bc-supports-yes">1</td>
<td class="bc-supports-yes">Yes</td>
<td class="bc-supports-yes">15</td>
<td class="bc-supports-yes">3</td>
<td class="bc-supports-yes">4.4</td>
<td class="bc-supports-yes">18</td>
<td class="bc-supports-yes">4</td>
<td class="bc-supports-yes">14</td>
<td class="bc-supports-yes">2</td>
<td class="bc-supports-yes">1.0</td>
</tr>
</tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li><a href="https://developer.mozilla.org/en-US/docs/Learn/Forms">HTML forms guide</a></li> <li>Other elements that are used when creating forms: <a href="button"><code>&lt;button&gt;</code></a>, <a href="datalist"><code>&lt;datalist&gt;</code></a>, <a href="fieldset"><code>&lt;fieldset&gt;</code></a>, <a href="input"><code>&lt;input&gt;</code></a>, <a href="label"><code>&lt;label&gt;</code></a>, <a href="legend"><code>&lt;legend&gt;</code></a>, <a href="meter"><code>&lt;meter&gt;</code></a>, <a href="optgroup"><code>&lt;optgroup&gt;</code></a>, <a href="option"><code>&lt;option&gt;</code></a>, <a href="output"><code>&lt;output&gt;</code></a>, <a href="progress"><code>&lt;progress&gt;</code></a>, <a href="select"><code>&lt;select&gt;</code></a>, <a href="textarea"><code>&lt;textarea&gt;</code></a>.</li> <li>Getting a list of the elements in the form: <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/elements"><code>HTMLFormElement.elements</code></a>
</li> <li><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/form_role">ARIA: Form role</a></li> <li><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/search_role">ARIA: Search role</a></li> </ul></div><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2005&ndash;2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
    <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form</a>
  </p>
</div>