Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

kbd — user input

The `kbd` element represents user input, usually keyboard input but also, for example, voice commands. Nesting can identify individual keys.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<kbd>user input</kbd>

kbd represents user input, not just keystrokes: it can also describe voice commands. It provides semantic markup, not a text-entry field or a mechanism for registering keyboard shortcuts.

It is allowed wherever phrasing content is expected and can contain phrasing content. Both tags are required. It supports global attributes and uses the HTMLElement interface.

An inner kbd inside another kbd represents one key or unit of input. kbd inside samp represents input echoed by the system; samp inside kbd represents input based on system output, such as selecting a menu item. By itself, samp describes output, while code describes program code.

In the example, the outer kbd groups the combination, while the two inner elements identify Ctrl and K. The document only describes the combination; it does not assign an action to it.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>kbd example</title>
<p>Key combination: <kbd><kbd>Ctrl</kbd> + <kbd>K</kbd></kbd></p>
</html>

Result

Key combination: Ctrl + K

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources