summaryrefslogtreecommitdiff
path: root/devdocs/html/global_attributes%2Finputmode.html
blob: 8cfc1cd32cbf485acb3096b76f5a4717f5a6eadd (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
<header><h1>inputmode</h1></header><div class="section-content">
<p> The <code>inputmode</code> <a href="../global_attributes">global attribute</a> is an <a href="https://developer.mozilla.org/en-US/docs/Glossary/Enumerated">enumerated</a> attribute that hints at the type of data that might be entered by the user while editing the element or its contents. This allows a browser to display an appropriate virtual keyboard. </p> <p>It is used primarily on <a href="../element/input"><code>&lt;input&gt;</code></a> elements, but is usable on any element in <a href="../global_attributes#contenteditable"><code>contenteditable</code></a> mode.</p> <p>It's important to understand that the <code>inputmode</code> attribute doesn't cause any validity requirements to be enforced on input. To require that input conforms to a particular data type, choose an appropriate <a href="../element/input#input_types"><code>&lt;input&gt; element type</code></a>. For specific guidance on choosing <a href="../element/input"><code>&lt;input&gt;</code></a> types, see the <a href="#values">Values</a> section.</p>
</div>
<h2 id="values">Values</h2>
<div class="section-content">
<p>The attribute can have any of the following values:</p> <dl> <dt id="none"><a href="#none"><code>none</code></a></dt> <dd> <p> No virtual keyboard. For when the page implements its own keyboard input control. </p> </dd> <dt id="text">
<a href="#text"><code>text</code></a> (default value)</dt> <dd> <p>Standard input keyboard for the user's current locale.</p> </dd> <dt id="decimal"><a href="#decimal"><code>decimal</code></a></dt> <dd> <p> Fractional numeric input keyboard containing the digits and decimal separator for the user's locale (typically <kbd>.</kbd> or <kbd>,</kbd>). Devices may or may not show a minus key (<kbd>-</kbd>). </p> </dd> <dt id="numeric"><a href="#numeric"><code>numeric</code></a></dt> <dd> <p> Numeric input keyboard, but only requires the digits 0–9. Devices may or may not show a minus key. </p> </dd> <dt id="tel"><a href="#tel"><code>tel</code></a></dt> <dd> <p> A telephone keypad input, including the digits 0–9, the asterisk (<kbd>*</kbd>), and the pound (<kbd>#</kbd>) key. Inputs that *require* a telephone number should typically use <code><a href="../element/input/tel">&lt;input type="tel"&gt;</a></code> instead. </p> </dd> <dt id="search"><a href="#search"><code>search</code></a></dt> <dd> <p> A virtual keyboard optimized for search input. For instance, the <a href="https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-enterkeyhint-attribute" target="_blank">return/submit key</a> may be labeled "Search", along with possible other optimizations. Inputs that <em>require</em> a search query should typically use <code><a href="../element/input/search">&lt;input type="search"&gt;</a></code> instead. </p> </dd> <dt id="email"><a href="#email"><code>email</code></a></dt> <dd> <p> A virtual keyboard optimized for entering email addresses. Typically includes the <kbd>@</kbd>character as well as other optimizations. Inputs that <em>require</em> email addresses should typically use <code><a href="../element/input/email">&lt;input type="email"&gt;</a></code> instead. </p> </dd> <dt id="url"><a href="#url"><code>url</code></a></dt> <dd> <p> A keypad optimized for entering URLs. This may have the <kbd>/</kbd> key more prominent, for example. Enhanced features could include history access and so on. Inputs that <em>require</em> a URL should typically use <code><a href="../element/input/url">&lt;input type="url"&gt;</a></code> instead. </p> </dd> </dl>
</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/interaction.html#attr-inputmode">HTML Standard <br><small># attr-inputmode</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>inputmode</code></th>
<td class="bc-supports-yes">66</td>
<td class="bc-supports-yes">79</td>
<td class="bc-supports-yes">9517–23</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">53</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">66</td>
<td class="bc-supports-yes">66</td>
<td class="bc-supports-yes">79</td>
<td class="bc-supports-yes">47</td>
<td class="bc-supports-yes">12.2</td>
<td class="bc-supports-yes">9.0</td>
</tr></tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li>All <a href="../global_attributes">global attributes</a>.</li> <li>
<a href="enterkeyhint"><code>enterkeyhint</code></a> global attribute</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/Global_attributes/inputmode" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode</a>
  </p>
</div>