HTML inputmode Attribute

Beginner
6 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The inputmode global attribute hints which on-screen keyboard a device should present for an editable control. Use it when you want a friendlier keypad without switching to a stricter type (for example keep type="text" but show a numeric pad).

Combine with enterkeyhint for the Enter key label, and with pattern / server validation for real constraints. inputmode never validates the value by itself.

Baseline · Widely available.

Modern mobile browsers honor the hint. Desktop physical keyboards are unchanged.

Still validate.

Users can paste or use a hardware keyboard. Enforce allowed characters in script and on the server.

HTML Syntax

syntax.html
<element inputmode ="none|text|decimal|numeric|tel|search|email|url">

Global attribute. Most useful on input, textarea, and contenteditable hosts.

Attribute Values

ValueDescriptionTry it
noneNo virtual keyboard (custom keypad UIs)Try it
textStandard text keyboard (default-like)Try it
decimalDigits plus a decimal separatorTry it
numericDigits (0–9), often for PINs/IDsTry it
telTelephone keypadTry it
searchText keyboard optimized for searchTry it
emailKeyboard with @ and easy domain entryTry it
urlKeyboard helpful for URLs (/ . com)Try it

Live Preview

Pick an inputmode and focus the field on a phone to see the keyboard change.

Best verified on a real mobile device or emulator.

Result

inputmode="numeric"

HTML Examples

Example 1 — Numeric and Decimal Pads

Show a digit keypad while keeping a text input for flexible formatting.

HTML
<label for="pin">PIN</label>
<input id="pin" name="pin" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code">

<label for="price">Price</label>
<input id="price" name="price" inputmode="decimal">
Try It Yourself

How It Works

  1. numeric for whole-digit values like PINs.
  2. decimal when a fractional separator is needed.
  3. Add pattern / validation if only digits are allowed.
  4. Prefer type when semantics fit — e.g. type="number" for true numeric fields.

Example 2 — Telephone Keypad

Offer a phone pad without forcing type="tel" if you need custom formatting.

HTML
<label for="phone">Phone</label>
<input id="phone" name="phone" type="text" inputmode="tel"
       autocomplete="tel" placeholder="+1 555 0100">
Try It Yourself

How It Works

  1. inputmode="tel" suggests a telephone keypad.
  2. type="tel" is often better when you want tel semantics end-to-end.
  3. autocomplete="tel" helps browsers offer saved numbers.
  4. Validate formats for your locale on the server.

Example 3 — Email and URL Keyboards

Help users type addresses and links with specialized keys.

HTML
<label for="mail">Email</label>
<input id="mail" name="mail" type="text" inputmode="email" autocomplete="email">

<label for="site">Website</label>
<input id="site" name="site" type="text" inputmode="url" autocomplete="url">
Try It Yourself

How It Works

  1. email surfaces @ and domain-friendly keys.
  2. url helps with slashes and TLDs.
  3. Consider type="email" / type="url" when you also want built-in validation.
  4. inputmode alone never rejects invalid values.

Edge Cases & Pitfalls

inputmode is a keyboard hint — never your only validation layer.

vs type

Prefer native types when they fit

type=email, url, tel, and number carry semantics and validation. Use inputmode when you need a text field with a better keypad.

paste

Users can still paste anything

Hardware keyboards and clipboard ignore your soft-keyboard wish.

none

none needs a custom keypad

If you hide the OS keyboard, provide an accessible alternative input UI.

desktop

Little desktop effect

Do not expect layout changes on laptops.

Browser Support

inputmode is an HTML attribute for browsers. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

inputmode

Widely supported on modern mobile browsers. Desktop usually unchanged.

96% Global support (approx.)
Google Chrome 66+
Full support
Mozilla Firefox 95+
Full support
Apple Safari 12.1+
Full support
Microsoft Edge 79+
Full support
Opera 53+
Full support
Samsung Internet 9+
Full support
Internet Explorer No support
Not supported
inputmode Widely supported

Bottom line: Safe progressive enhancement for virtual keyboards.

Key Takeaways

  • Role: hint the on-screen keyboard layout.
  • Values: none, text, decimal, numeric, tel, search, email, url.
  • Not validation: still check values yourself.
  • Pair with type, pattern, and enterkeyhint as needed.

One line: inputmode asks for the right soft keyboard without changing the field type.

Frequently Asked Questions

It hints which virtual keyboard layout to show for editable text — for example numeric, tel, email, or url. It does not change the field’s value type or validation by itself.
No. type=number or type=email changes semantics, UI, and validation. inputmode only suggests a keyboard while keeping a text-like control when you need freer input.
numeric is digits (often for PINs or IDs). decimal adds a decimal separator for amounts like prices.
It requests that no virtual keyboard is shown — useful when you provide a custom on-screen keypad.
Usually no visible effect on physical keyboards. Benefits show on phones and tablets.
Yes — widely available on modern browsers, especially mobile.

Next: integrity

Protect scripts and stylesheets with Subresource Integrity hashes.

integrity tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful