kbd – keyboard input
<kbd>Ctrl</kbd>+<kbd>C</kbd>
Input from the user: a key, a keyboard shortcut, text they should type or a voice command. A keyboard shortcut is written as nested kbd elements, one for each key. The browser displays it in a monospaced font (font-family: monospace; when the page does not set a font size, browsers shrink it from 16 px to 13 px).
- Default display:
display: inline - End tag: required
- Content: phrasing content
- Where it can be used: anywhere phrasing content is allowed
- DOM interface:
HTMLElement
Attributes
Only global attributes.
Examples
A keyboard shortcut with the keys drawn as keycaps:
<p>Save the page with <kbd><kbd>Ctrl</kbd>+<kbd>S</kbd></kbd>.</p>
kbd kbd {
padding: 1px 6px;
border: 1px solid #bbb;
border-bottom-width: 2px;
border-radius: 4px;
background: #f7f7f7;
}
Things to watch out for
- Program output (a message, the result of a command) is
samp, code iscode. - On a Mac it is usually Cmd instead of Ctrl – give both variants for shortcuts.
Browser support
Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 1, Firefox 1, Safari 4. As of October 2026 (MDN browser-compat-data).
Related:
code – code
samp – program output
accesskey – keyboard shortcut (attribute)