HTML <kbd> Tag
The HTML <kbd> Tag tag is used to define keyboard input. It is typically used to display user input, such as keyboard shortcuts or code snippets, in a monospace font. This tag is a part of the HTML phrasing content.
Here is an example of using the HTML <kbd> Tag tag:
<p>To save a document, press <kbd>Ctrl + S</kbd></p>
When rendered in a browser, the above code will display as:
To save a document, press Ctrl + S
Main Tag Attributes of the Tag
Attribute | Description |
---|---|
global attributes | Applies to all HTML elements |
The tag does not have any unique attributes, but it can be combined with global attributes for styling and behavior.
Example:
<p>To create a new file, press <kbd style="color: red;">Ctrl + N</kbd></p>
When rendered in a browser, the above code will display as:
To create a new file, press Ctrl + N