The HTML inputmode attribute
The HTML inputmode attribute hints what kind of data a user will enter so mobile browsers show the most useful on-screen keyboard, such as numeric, tel, email, url, decimal or search. It is a global attribute, most valuable on form fields.
Overview
The inputmode attribute lets you optimize the on-screen keyboard without changing an input's type. For example, a one-time-code field can stay type="text" for validation but use inputmode="numeric" to summon a number pad.
It only affects the virtual keyboard layout; it does not perform validation or change the submitted value. Choose the mode that matches the expected characters, and combine it with enterkeyhint for the smoothest mobile experience.
Values
| Value |
|---|
| none | text | decimal | numeric | tel | search | email | url |
Example
<input inputmode="numeric" placeholder="Enter a numeric code" style="padding:8px; width:100%;">
Best practices
- There is no number keyword for inputmode. Write
numericfor digits ordecimalfor fractions, becauseinputmode="number"is invalid and leaves the browser to choose its default keyboard. - Avoid
numericanddecimalfor values that can be negative, such as a temperature offset, because devices may or may not show a minus key on those keyboards. - Pick
telfor phone numbers andnumericfor PINs. The tel keypad should include * and # as well as digits, while numeric is only required to offer the digits 0 to 9. - An editor that draws its own on-screen keypad, such as a calculator, is the place for
inputmode="none", because the browser should then show no virtual keyboard at all. - On a custom editor built with contenteditable, set the mode on the editing host itself, since there is no type attribute there to choose a keyboard.
Frequently asked questions
What does the inputmode attribute do?
Is inputmode guaranteed to work?
What is the difference between inputmode and the input type?
inputmode only suggests which on-screen keyboard layout to show.






















