HTML <kbd> Tag
In this post, we will cover HTML Tag Kbd and examples. With the aim that it would serve the learning requirements.
The HTML <kbd> tag is used to mark text as keyboard input. This can be useful for indicating keyboard shortcuts, command names, or any other text that represents input from a keyboard.
The <kbd> tag has no required attributes, but it can be styled with CSS to change the appearance of the enclosed text.
Describe some content in a document as keyboard input:
Example: 
The <kbd> element is styled with CSS as follows:
Example: 
Here is an example of the kbd and ins tag together:
Example: 
Tag Kbd Usage
Controlling keyboard input is done through the Tag <kbd>. For content shown inside a browser, use monospace fonts by default.
Also look at:
Tag | Overview |
---|---|
<samp> | Provide an example of output from a computer program. |
<pre> | Describes preformatted text. |
<code> | Provides information about a block of computer code. |
<var> | Create a variable. |
Browser Compatibility
Element | |||||
---|---|---|---|---|---|
<kbd> | Yes | Yes | Yes | Yes | Yes |
Global
Event
The Event Attributes are also compatible with HTML’s Tag <kbd>.
Predefined CSS
The <kbd> element will often be displayed with the following default values:
kbd { font-family: monospace; }
HTML <kbd> Tag Advantages
The HTML <kbd> tag has several advantages when used in web development:
- The <kbd> tag can help improve the accessibility of a web page by providing additional context for users with screen readers or other assistive technologies. By indicating text as keyboard input, users can more easily understand the purpose of the input and navigate the page more effectively.
- The <kbd> tag can improve the readability of text that represents keyboard input. By visually distinguishing keyboard input from other text, readers can more easily understand the purpose of the input and follow instructions.
- Using the <kbd> tag can help maintain a consistent visual style for keyboard input across a web page or application. This can help users quickly identify input fields and navigate the page more efficiently.
- The <kbd> tag can be styled using CSS to match the design of a web page or application. This can help create a more cohesive and visually appealing user interface.
- The <kbd> tag is widely supported across modern web browsers, ensuring that keyboard input is consistently displayed regardless of the user’s browser or operating system.