CSS Portal

HTML inputmode Global Attribute

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The inputmode attribute is designed to improve how users interact with input fields, especially on devices that use virtual or on-screen keyboards. Rather than controlling what users can enter, it influences how they enter information by suggesting the most appropriate input method for the expected data.

Its primary role is usability enhancement, not validation or formatting enforcement.

How inputmode Works

When a user focuses on a field that includes the inputmode attribute, the browser interprets it as a hint about the type of input expected. Based on this hint, the device may adjust the on-screen keyboard layout to better suit the task.

This is particularly beneficial on mobile and tablet devices, where keyboard layout changes can significantly improve typing speed, accuracy, and comfort.

On desktop devices, the effect is usually minimal or unnoticeable, as physical keyboards are already optimized for full input.

Input Guidance Without Restrictions

One of the most important characteristics of inputmode is that it does not restrict user input. Users can still enter any characters their device allows, even if those characters do not align with the suggested input type.

Because of this, inputmode should never be relied upon for validation or data enforcement. Any data checking or formatting must be handled separately using form validation logic or scripting.

Relationship to Other Input Attributes

While attributes such as input type define how data is interpreted or validated, inputmode focuses purely on the user experience. The two can work together to create more intuitive and user-friendly forms.

For example, a form may visually encourage a certain kind of input while still allowing flexibility behind the scenes. This separation of responsibility makes inputmode a valuable enhancement rather than a constraint.

Use with Editable Content

The attribute is not limited to traditional form fields. It can also be applied to editable content areas, such as elements that allow direct user editing. This makes it useful in custom interfaces, rich text editors, or applications that simulate form behavior without using standard form elements.

In these cases, inputmode helps ensure the correct input method appears even when no standard input field is present.

Accessibility Benefits

From an accessibility standpoint, inputmode improves the experience for users who rely on touch interfaces or assistive technologies. By reducing friction during text entry, it helps users interact more efficiently and with fewer errors.

However, it should always be used alongside proper labeling, logical structure, and accessible design practices. It enhances accessibility but does not replace foundational accessibility requirements.

Impact on User Experience

When used thoughtfully, inputmode can:

  • Reduce user frustration during data entry
  • Improve form completion speed
  • Minimize typing errors on small screens
  • Create a more polished and intentional interface

These benefits are especially noticeable in mobile-first designs or applications that rely heavily on user input.

Limitations and Considerations

  • Browser and device behavior may vary slightly in how the input method is displayed.
  • It does not guarantee a specific keyboard layout.
  • It does not prevent invalid input.
  • It should not be relied upon as a security or validation mechanism.

Despite these limitations, it remains a powerful usability enhancement when used appropriately.

Best Practices

  • Use it to complement, not replace, proper validation logic.
  • Apply it where input expectations are clear and consistent.
  • Combine it with clear labels and instructions.
  • Avoid overusing it where it provides little practical benefit.

Syntax

<input inputmode="value">

Values

  • noneDisables the virtual keyboard entirely.
  • textThe default system keyboard for the user's locale.
  • decimalNumbers and a decimal separator (usually a dot or comma).
  • numericNumbers only (0–9). Usually no decimal point.
  • telDisplays a telephone-style keypad.
  • searchDisplays a keyboard optimized for search input.
  • emailShows a keyboard optimized for email entry (often includes @ and . keys).
  • urlDisplays a keyboard optimized for entering URLs.

Example

<form>
<label>
Phone Number:
<input type="text" inputmode="tel" placeholder="e.g. 0412 345 678">
</label>

<br><br>

<label>
Age:
<input type="text" inputmode="numeric" placeholder="e.g. 25">
</label>

<br><br>

<label>
Email Address:
<input type="email" inputmode="email" placeholder="name@example.com">
</label>

<br><br>

<label>
Search:
<input type="search" inputmode="search" placeholder="Search...">
</label>
</form>

Browser Support

The following information will show you the current browser support for the HTML inputmode global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 27th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!