Code has been added to clipboard!

HTML kbd Tag

Reading time 2 min
Published Jun 29, 2017
Updated Sep 11, 2019

HTML kbd Tag: Main Tips

  • <kbd> tag is the keyboard input tag (one of the phrase tags).
  • You can customize the <kbd> HTML using additional CSS.
  • Use it for short commands and not phrases.

Use of kbd

HTML <kbd> identifies a user keyboard entry. Which is why it's extremely useful when displaying user documentation (such as which onscreen or keyboard button you should press), keystrokes, and even instructions for echoed commands (when the system repeats what was inputted). These distinctions can be achieved by nesting kbd tag within samp or more kbd tags:

  • If you nest kbd element inside samp tag, it will act like echoed command: it will output the input command which was typed earlier (i.e.My Input).
  • If you nest kbd element, it will be seen as a keystroke representation (i.e. CTRL).
  • If you nest samp inside kbd tag, it will display onscreen input options, such as navigational or button names (i.e.Cancel).

This tag is typically displayed in a plain, fixed-width (monospace) font.

Example
<kbd>CTRL</kbd> 
<kbd>ALT</kbd>

Remember: the default kbd HTML styling is in the monospace font.

The following example styles the HTML <kbd> with CSS:

Example
<p>Please press <kbd>CTRL</kbd> + <kbd>ALT</kbd> to undo the last operation.</p>

It's recommended to style kbd elements as otherwise they look identical to code elements.

Note: there are no specific attributes for HTML kbd. However, it includes all global attributes.

Browser Support

Chrome
All
Edge
All
Firefox
1+
IE
All
Opera
All
Safari
All

Mobile Browser Support

Chrome
All
Firefox
4+
Opera
All
Safari
All
Basics
Introduction
Syntax
Editors
Basic Examples
Head Section
<!DOCTYPE>
Tags and Elements
Semantic Elements
Tags Reference
Attributes
Comments
Block and Inline Elements
Forms
Form Elements
Input
Responsive Web Design
Inline Scripts
Uniform Resource Locator
Redirect
XHTML
Geolocation
Drag and Drop
Local Storage
Web Workers
Server-Sent Events
Character Encoding
Text Formatting
Quotation and Citation Elements
Headings
Paragraphs
Links
Tables
Lists
Symbols
Space
Tab
Styles
Computer Code
Layout
Classes
Colors
Images
iframes
Audio Player
Video Player
YouTube Videos
Multimedia
Canvas
SVG
<!-- -->
<a>
<abbr>
<acronym> DEPRECATED
<address>
<applet> DEPRECATED
<article>
<aside>
<audio>
<b>
<base>
<basefont> DEPRECATED
<bdi>
<bdo>
<big> DEPRECATED
<blink> DEPRECATED
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center> DEPRECATED
<cite>
<code>
<col>
<colgroup>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir> DEPRECATED
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font> DEPRECATED
<footer>
<form>
<frame> DEPRECATED
<frameset> DEPRECATED
<h1> – <h6>
<head>
<header>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen> DEPRECATED
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<menuitem> DEPRECATED
<meta>
<meter>
<nav>
<noframes> DEPRECATED
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike> DEPRECATED
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt> DEPRECATED
<u>
<ul>
<var>
<video>
<wbr>