Open In App

HTML <kbd> Tag

Last Updated : 26 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

It is a phrase tag and is used to define the keyboard input. The text enclosed within <kbd> tag is typically displayed in the browser's default monospace font.

Syntax:

<kbd> text content ... </kbd>

List of all phrase tag: 

  • <em>: It is used to emphasize the text.
  • <strong>: It is used to define an important text.
  • <code>: It encloses the computer code.
  • <samp>: It defines a sample output text from a computer program.
  • <kbd>: It defines the text of keyboard input.
  • <var>: It defines the variable text.

Example 1: This example describe the use of <kbd> tag.

html
<!DOCTYPE html>
<html>

<body>
    <h1>GeeksforGeeks</h1>

    <h3>HTML kbd Tag</h3>


    <p>
        Open a new window using the
        keyboard shortcut
        <kbd>Ctrl</kbd> + <kbd>N</kbd>
    </p>

</body>

</html>

Output: 
 

Example 2: This example using <kbd> tag with some CSS styles.

HTML
<!DOCTYPE html>
<html>

<head>
    <style>
        kbd {
            border-radius: 2px;
            padding: 2px;
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h2>HTML kbd Tag</h2>


    <p>Open a new window using the
        keyboard shortcut
        <kbd>Ctrl</kbd>+<kbd>N</kbd>
    </p>

</body>

</html>

Output:


Supported Browsers: 


Next Article

Similar Reads

  翻译: