HTML inputmode 属性

定义和用法

inputmode 属性允许您更改手机或平板电脑(任何带有虚拟键盘的设备)上键盘的外观。

另请参阅:

HTML 教程:HTML attributes

实例

提示:请在手机或平板电脑上运行实例,以查看结果。

例子 1

在(虚拟)键盘上只显示数字键:

<input type="text" inputmode="numeric">
Resultatet af inputmode-attributtet på mobil

亲自试一试

例子 2

下面的实例使用了 "email" 的 "inputmode":

<input type="text" inputmode="email">
Resultatet af inputmode-attributtet på mobil

亲自试一试

语法

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

Attribute value

Value Description
decimal Only display numeric keyboard, usually with a comma key.
email Text keyboard, keys are usually used for email addresses, such as [@].
none Keyboard should not appear.
numeric Only display numeric keyboard.
search Text keyboard, the [enter] key is usually displayed as [go].
tel Only display numeric keyboard, usually with [+]、[*] and [#] keys.
text Default. Text keyboard.
url Text keyboard, keys are usually used for URLs, such as [.] and [/], as well as special [.com] keys, or other domain name endings commonly used in local settings.

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
66 79 95 12.2 53