Code has been added to clipboard!

HTML kbd Tag

Reading time 2 min
Published Jun 29, 2017
Updated Sep 11, 2019

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.
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

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 kbd element inside samp tag, it will act like echoed command: it will output the input command which was typed earlier (i.e.My Input).
  • If you nest kbd element, it will be seen as a keystroke representation (i.e. CTRL).
  • If you nest samp inside kbd tag, 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.

Example
<kbd>CTRL</kbd> 
<kbd>ALT</kbd>

Remember: the default kbd HTML styling is in the monospace font.

The following example styles the HTML <kbd> with CSS:

Example
<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

Browser image
Chrome
All
Browser image
Edge
All
Browser image
Firefox
1+
Browser image
IE
All
Browser image
Opera
All
Browser image
Safari
All

Mobile Browser Support

Browser image
Chrome
All
Browser image
Firefox
4+
Browser image
Opera
All
Browser image
Safari
All

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 27/02/2021
3176 People Used
Only 97 Left
Rating
5.0