kbd
elementHTMLElement
.The kbd
element represents
user input (typically keyboard input, although it may also be used
to represent other input, such as voice commands).
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.
Here the kbd
element is used to indicate keys to
press:
<p>To make George eat an apple, press <kbd><kbd>Shift</kbd>+<kbd>F3</kbd></kbd></p>
In this second example, the user is told to pick a particular
menu item. The outer kbd
element marks up a block of input, with the
inner kbd
elements representing each individual step
of the input, and the samp
elements inside them indicating that
the steps are input based on something being displayed by the
system, in this case menu labels:
<p>To make George eat an apple, select <kbd><kbd><samp>File</samp></kbd>|<kbd><samp>Eat Apple...</samp></kbd></kbd> </p>
Such precision isn't necessary; the following is equally fine:
<p>To make George eat an apple, select <kbd>File | Eat Apple...</kbd></p>