Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between kbd and code tags?

Tags:

html

I don't think it is possible that HTML5 specifications introduce repeated tags that do the same thing. I need, exactly, what is the practically and hypothetically difference between both <kbd> and <code> tags?

This demo shows that they have the same effect!

like image 516
SaidbakR Avatar asked Jan 11 '23 01:01

SaidbakR


1 Answers

It’s not clear what exactly you are asking about, however, you can find all the differences and similarities in the HTML5 spec. For example:

Meaning

The kbd element

represents user input […]

The code element

represents a fragment of computer code […]

Content model, attributes etc.

The same. Both are flow content / phrasing content / palpable content. Both have the phrasing content content model. Both can only have the global attributes, same ARIA roles etc.

Styling

They have the same default styling:

code, kbd, samp, tt { font-family: monospace; }
like image 74
unor Avatar answered Jan 23 '23 03:01

unor