Can the kbd
element be used according to its definition in the HTML5 (CR) spec, or do we have further restrictions for its use on Stack Exchange sites?
The editing help only gives an example, but no definition/help. The linked answer to "What HTML tags are allowed on Stack Exchange sites?" says:
<kbd>
- shows keyboard input
But I’m not sure if this is meant to be the definitive definition for its use.
The HTML5 (CR) spec says that kbd
represents "user input", not necessarily "keyboard input".
So the following examples should be valid according to HTML5 (CR):
Just press Ctrl+f.
I assume this usage is, without question, appropriate on SE.
Just press Ctrl+f.
If someone uses this structure, it often gets edited by someone else, making it look like the first example.
(Also mentioned in Ban <kbd>, its usage and rendering are incorrect.)
Then click on Post Your Question.
What about this? When I use/saw this, sometimes it gets edited (e.g., removed kbd
and added i
or quotation marks), sometimes not.
To make it clear: in this example, kbd
is not used to make the text look like a button, but because it is a button, i.e., this text is used on a button which the user should "activate" (whether by keyboard or mouse or voice …).
Just for the record, some more (complex) examples of the previous case:
- You can find it at File → Export → Export as XML
- You can find it at File → Export → Export as XML
- You can find it at File → Export → Export as XML
- You can find it at File | Export | Export as XML
And also (but here could code
be used instead):
- Enter answers:0 to find all questions with no answers.
While the question Stricter <kbd> usage rules is about a similar topic, it is mostly about usage that is wrong according to HTML5.
kbd
element is nested inside anotherkbd
element, it represents an actual key or other single unit of input as appropriate for the input mechanism." If they were to be pressed together (at the same time), one would probably use it (example 1 or 2) without the+
character.kbd
tags to link to outside sites like sql fiddle.