totn HTML

HTML: <kbd> tag

This HTML tutorial explains how to use the HTML element called the <kbd> tag with syntax and examples.

Description

The HTML <kbd> tag defines text as user input from a keyboard such as the Enter or Ctrl keys. Browsers traditionally render the text found within the <kbd> tag in the default monospace font. This tag is also commonly referred to as the <kbd> element.

Syntax

In HTML, the syntax for the <kbd> tag is:

<body>
<p>Press <kbd>Enter</kbd> to continue</p>
</body>

Sample Output


Attributes

Only the Global Attributes apply to the <kbd> tag. There are no attributes that are specific to the <kbd> tag.

Note

  • The HTML <kbd> element is found within the <body> tag.
  • The <kbd> tag is used to signify a key stroke on the keyboard. Browsers traditionally format the text found within the <kbd> tag as monospace font. You can change this behavior with CSS.

Browser Compatibility

The <kbd> tag has basic support with the following browsers:

  • Chrome
  • Android
  • Firefox (Gecko)
  • Firefox Mobile (Gecko)
  • Internet Explorer (IE)
  • Edge Mobile
  • Opera
  • Opera Mobile
  • Safari (WebKit)
  • Safari Mobile

Example

We will discuss the <kbd> tag below, exploring examples of how to use the <kbd> tag in HTML5, HTML 4.01 Transitional, XHTML 1.0 Transitional, XHTML 1.0 Strict, and XHTML 1.1.