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.
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
- A wide range of learning programs
- University-level courses
- Easy to navigate
- Verified certificates
- Free learning track available
- University-level courses
- Suitable for enterprises
- Verified certificates of completion
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
kbdelement insidesamptag, it will act like echoed command: it will output the input command which was typed earlier (i.e.My Input). - If you nest
kbdelement, it will be seen as a keystroke representation (i.e. CTRL). - If you nest
sampinsidekbdtag, 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.
Remember: the default kbd HTML styling is in the monospace font.
The following example styles the HTML <kbd> with CSS:
<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
Edge
Firefox
IE
Opera
Safari
Mobile Browser Support
Chrome
Firefox
Opera