Super User and the other SE sites have support for the HTML <kbd> tag, denoting keys that should be pressed. These are styled in order to look like a physical keyboard key.
On the W3C wiki page about <kbd>, three more advanced uses of the element are suggested:
- When the
kbdelement is nested inside asampelement, it represents the input as it was echoed by the system.- When the
kbdelement contains asampelement, it represents input based on system output, for example invoking a menu item.- When the
kbdelement is nested inside anotherkbdelement, it represents an actual key or other single unit of input as appropriate for the input mechanism.
So I propose the following styling for keyboard input in light of these recommendations:
<kbd>ls -la</kbd>represents a command the user should type. It should be more styled than`ls -la`would, but shouldn't look like a key.<kbd><kbd>Enter</kbd></kbd>represents the user pressing a key, and should look like an actual key.
It seems the <samp> element is currently unsupported, but if it were, the other suggestions could be styled as well. Of course, there is a point where we could have simply too many different styles, and we'd get visual clutter.
The most evident concern I see with this plan would be the fact that most answers to date have been written expecting that <kbd> would look like a key. Assuming a global replacement of <kbd>...</kbd> with <kbd><kbd>...</kbd></kbd> would be impractical, we'd have to come up with some other solution.
kbdelement in posts. It took me a while to figure it out when I was new to the site. – slhck Jun 20 '11 at 4:39