The HTML <kbd> element represents user input and produces an inline element displayed in the browser's default monospace font.
| Content categories | Flow content, phrasing content, palpable content. |
|---|---|
| Permitted content | Phrasing content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents | Any element that accepts phrasing content. |
| Permitted ARIA roles | Any |
| DOM interface |
HTMLElement Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the interface HTMLSpanElement for this element. |
This element only includes the global attributes.
<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>
A CSS rule can be defined for the kbd selector to override the browser's default font face. Preferences set by the user might take precedence over the specified CSS.
When the <kbd> element is nested inside a <samp> element, it represents the input as it was echoed by the system.
When the <kbd> element contains a <samp> element, it represents input based on system output, for example invoking a menu item.
When the <kbd> element is nested inside another <kbd> element, it represents an actual key or other single unit of input as appropriate for the input mechanism.
| Specification | Status | Comment |
|---|---|---|
| WHATWG HTML Living Standard The definition of '<kbd>' in that specification. | Living Standard | |
| HTML5 The definition of '<kbd>' in that specification. | Recommendation | Expanded to include any user input, like voice input and individual keystrokes. |
| HTML 4.01 Specification The definition of '<kbd>' in that specification. | Recommendation |
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
| Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd