Summary
The HTML Keyboard Input Element (<kbd>) 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 {{no_tag_omission}}
- Permitted parent elements Any element that accepts phrasing content.
- DOM interface {{domxref("HTMLElement")}} Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the interface {{domxref("HTMLSpanElement")}} for this element.
Attributes
This element only includes the global attributes.
Examples
<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>
Result
{{ EmbedLiveSample('Examples', 350, 120) }}
Note
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.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-kbd-element', '<kbd>')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-kbd-element', '<kbd>')}} | {{Spec2('HTML5 W3C')}} | Expanded to include any user input, like voice input and individual keystrokes. |
{{SpecName('HTML4.01', 'struct/text.html#h-9.2.1', '<kbd>')}} | {{Spec2('HTML4.01')}} |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoMobile("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
See also
- {{htmlelement("code")}}