HTML kbd tag
The <kbd>
tag is used to define keyboard input. The user agent defaults to rendering the contents of a <kbd>
element using its default monospace font, although this is not mandated by the HTML standard.
Here is an example of how you might use the kbd tag in an HTML document:
<kbd>Shift</kbd>
/* Default style */
kbd {
font-family: monospace;
}
This would render the text “Shift” in a monospaced font, indicating that these are keys that the user needs to press.
You can also use the kbd tag in conjunction with other HTML elements, such as the samp tag, which is used to represent output from a computer program. For example:
<p>To list the files in the current directory, type <kbd>ls</kbd> and press <kbd>Enter</kbd>:</p>
<p><samp>file1.txt file2.txt file3.txt</samp></p>
This would render the text “ls” and “Enter” in a monospaced font, indicating that these are user input, and the text “file1.txt file2.txt file3.txt” in a default font, indicating that this is the output from the computer.