- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <kbd> Tag
HTML Tags
HTML <kbd> Tag
The kbd tag marks keys or text the user should type: Ctrl + S, Enter, the command cmd. It shows in a monospace font, and it tells readers and screen readers "press this".
It belongs to a small family: code for code, samp for what the computer prints, and <kbd> for what the user enters.
Syntax
html
<kbd>keyboard input</kbd>It has no attributes of its own, only the global ones.
Example
html
<!DOCTYPE html>
<html>
<head>
<title>HTML kbd Tag Example</title>
</head>
<body>
<h2>HTML <kbd> Tag Example</h2>
<p>To save the document, press <kbd>Ctrl</kbd> + <kbd>S</kbd>.</p>
<p>To refresh a webpage, press <kbd>F5</kbd>.</p>
<p>To open the command prompt, type <kbd>cmd</kbd> in the Run dialog.</p>
</body>
</html>The keys Ctrl, S and F5 and the command cmd appear in a monospace font, so they stand out from the instructions around them.
Key combinations
Wrap each key in its own <kbd>, and you can style them like real keys:
A shortcut that looks like keyboard keys
html
<style>
kbd {
border: 1px solid #94a3b8;
border-bottom-width: 2px;
border-radius: 4px;
padding: 0 0.35em;
font-size: 0.9em;
}
</style>
<p>Copy with <kbd>Ctrl</kbd> + <kbd>C</kbd>.</p>For something the user types, like a command, one <kbd> around the whole text is enough.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
- Write shortcuts for both systems when they differ:
Ctrlon Windows,⌘ Cmdon a Mac. - Use the key names printed on keyboards, like "Enter" and "Shift", so readers can find them.
HTML <kbd> Tag exercises
Mark a key
Write this paragraph with the key marked as keyboard input: Press Enter to continue.
Result
