What does the HTML inputmode attribute do, and how is it different from an input's type attribute?
answer
- a hint, not a contract
- keyboard layout versus control semantics
- numeric and decimal are not the same keypad
- invisible on a laptop
- relabelling the Enter key changes no behaviour
basics
~20 sinputmode is a hint that tells a device which virtual keyboard layout to show. It changes no semantics, no validation and no value handling — unlike type, which selects the control, its value grammar, its built-in validity check and its accessible role.
solid answer
~50 s`inputmode` answers one question only: which on-screen keyboard should appear when this field is focused. Its values are `none`, `text`, `decimal`, `numeric`, `tel`, `search`, `email` and `url`. It is a global attribute, so it also works on a `contenteditable` region, and it has no effect at all with a hardware keyboard. `type` is a much bigger lever: it picks which control the browser renders, what value grammar is accepted, whether the value is sanitised, what built-in validation runs, and which accessible role is exposed. That difference is exactly why the pairing `type="text" inputmode="numeric"` is the standard answer for identifiers — you get the numeric keypad without the number-parsing semantics. A sibling attribute, `enterkeyhint`, takes `enter`, `done`, `go`, `next`, `previous`, `search` or `send` and only relabels the on-screen Enter key; it does not change what pressing Enter actually does.
code
html · 11 lines<!-- Keypad without number semantics -->
<label for="pin">PIN</label>
<input id="pin" name="pin" type="text" inputmode="numeric" maxlength="4">
<!-- Money needs the decimal separator on the keypad -->
<label for="amount">Amount</label>
<input id="amount" name="amount" type="text" inputmode="decimal">
<!-- Relabel the on-screen action key only -->
<label for="q">Search</label>
<input id="q" name="q" type="search" enterkeyhint="search">go deeper
Know that inputmode picks the on-screen keyboard and nothing else, and that type="text" with inputmode="numeric" is the standard way to get a keypad for a code or postcode.
Be able to list the real values, contrast numeric with decimal, and explain precisely which properties come from type — widget, grammar, validation, role — versus which are only keyboard hints.
Show the field judgment: hints are ignorable, do nothing on desktop, and never substitute for validation, so the value must still be treated as free text everywhere downstream.
Own the input-hint conventions in the design system so every numeric-string field ships the same type, keyboard hint and action-key label instead of each team reinventing them.
## Two attributes, two jobs A common interview probe is to ask a candidate to distinguish a *behavioural* attribute from a *presentational hint*. `type` and `inputmode` are the cleanest example in HTML. `type` selects an input **state**. The state determines the widget the browser renders, the grammar the value must satisfy, whether the browser rewrites an unparseable value, which built-in validity checks apply, and which implicit ARIA role the control exposes. Change the type and you change what the field *is*. `inputmode` is a **hint to the input method**. It tells a device with a software keyboard which layout would be most useful. Nothing else. It does not validate, does not sanitise, does not change the role, does not affect what a hardware keyboard can type, and the user can always switch layouts manually. ## The values and what they buy - `none` — request no virtual keyboard at all. Used when the page supplies its own on-screen input surface, such as a custom PIN pad or a calculator widget. Use it sparingly: it removes the user's normal way to type. - `text` — the standard keyboard; the default for text-shaped fields. - `numeric` — digits only. Correct for PINs, postcodes, verification codes, quantities entered as strings. - `decimal` — digits plus the locale's decimal separator, and typically no plus/minus. Correct for money and measurements. - `tel` — the telephone keypad, usually with `+`, `*` and `#`. - `search` — a keyboard whose action key is oriented to searching. - `email` — a layout with `@` and `.` on the primary layer. - `url` — a layout with `/` and often a `.com`-style key. The distinction people miss most often is `numeric` versus `decimal`: a currency field with `inputmode="numeric"` gives a keypad on which the user cannot type the decimal point. ## Why the pairing exists ```html <label for="otp">Verification code</label> <input id="otp" name="otp" type="text" inputmode="numeric" maxlength="6"> ``` Before `inputmode` was widely supported, `type="number"` was the only way to get a numeric keypad on a phone — which is how a whole generation of forms ended up modelling postcodes and codes as quantities, with spin buttons, stepping keys and a value that empties itself when it cannot be parsed. `inputmode` decouples the keyboard from the semantics: `type="text"` keeps the value a plain string with a textbox role, while the hint still gets the keypad. Any time you want "the keyboard of X without the behaviour of X", this is the tool. The inverse holds too. `inputmode` never rescues a wrong type. Putting `inputmode="text"` on a number input does not remove the spinner or the value sanitising, because those come from the state, not the keyboard. ## It is a global attribute `inputmode` is defined as a global attribute, not an input-only one, so it applies to editing hosts as well: ```html <div contenteditable="true" inputmode="numeric">42</div> ``` That is a small but genuine differentiator in an interview, because it shows you know the attribute is about the *input method* rather than about form controls specifically. ## enterkeyhint `enterkeyhint` is the other virtual-keyboard hint worth knowing. It relabels the action key — the values are `enter`, `done`, `go`, `next`, `previous`, `search` and `send`. ```html <input type="search" name="q" enterkeyhint="search"> ``` Critically, it is cosmetic. Labelling the key `next` does not make the browser move focus to the next field; the key still does whatever it would have done, and if you want a different action you implement it. It is a promise to the user about what will happen, so a mismatch between the label and the actual behaviour is worse than no hint at all. ## What to say when asked Lead with the one-line difference: `type` decides what the control *is*, `inputmode` decides what keyboard the device *offers*. Then give the pairing that proves you understand the split — `type="text" inputmode="numeric"` for identifiers — and note the honest limits: it is a hint, it is ignorable, it does nothing on a laptop, and it validates nothing.
- When would inputmode="decimal" be wrong and inputmode="numeric" right?Use `numeric` when the value is digits only — a PIN, a one-time code, a postcode, a whole-unit quantity — because that keypad hides the separator the user must not type. Use `decimal` for money, weights and measurements, where the user genuinely needs the locale's decimal separator. Picking `numeric` for a currency field is a classic bug report: people simply cannot enter the cents.
- Does enterkeyhint="next" move focus to the next field?No. It only relabels the action key on the virtual keyboard; the key's behaviour is unchanged. If you want Enter to advance focus you implement that yourself, and you should — a key labelled "next" that submits the form is a worse experience than an unlabelled one, because the hint made a promise the page did not keep.
- Can inputmode fix an input that was wrongly given type="number"?No. Spin buttons, arrow-key stepping, the spinbutton role and the value-sanitising step all come from the input state, and a keyboard hint cannot undo any of them. Setting `inputmode="text"` on a number input just requests a different keypad on top of unchanged semantics. The fix is to change the type and then add the hint.
saying these in an interview costs you the question
- Thinks inputmode restricts which characters can be entered
- Says inputmode changes the field's validation or role
- Uses inputmode=numeric on a currency field
- Believes enterkeyhint changes what pressing Enter does
- Assumes inputmode only works on input elements