Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<kbd>

翻译正在进行中。

摘要

HTML键盘输入元素(<kbd>) 用于表示用户输入,它将产生一个行内元素,以浏览器的默认monospace字体显示。

Content categories Flow content, phrasing content, palpable content.
Permitted content Phrasing content.
Tag omission 不允许,开始标签和结束标签都不能省略。
Permitted parent elements Any element that accepts phrasing content.
DOM interface HTMLElement Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the interface HTMLSpanElement for this element.

属性

该元素仅支持全局属性.

示例

<p>Type the following in the Run dialog: <kbd>cmd</kbd><br />Then click the OK button.</p>

<p>Save the document by pressing <kbd>Ctrl</kbd> + <kbd>S</kbd></p>

结果

注意

通过定义CSS规则可以改变kbd的默认字体。用户首选项设置可能会比该CSS规则具有更高优先级。

当<kbd>元素处于<samp>元素之中时,它代表着被系统回显的输入。

当<kbd>元素中包含<samp>元素时,该输入是基于系统输出的,比如调用某个菜单项。

当<kbd>元素处于另一个<kbd>元素之中时,它代表了一个实际的按键,或是该输入机制下的某个单位输入。

规范

Specification Status Comment
WHATWG HTML Living Standard
<kbd>
Living Standard  
HTML5
<kbd>
Recommendation Expanded to include any user input, like voice input and individual keystrokes.
HTML 4.01 Specification
<kbd>
Recommendation  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)

参阅

文档标签和贡献者

 此页面的贡献者: perillasy
 最后编辑者: perillasy,