Monday 21 April 2014

css for Keyboard input tag kbd


Describing a keyboard shortcut can be done by using the tag <kbd>, it is a phrase tag and defines keyboard input in the browser's default monotype font.
By using css you can make the code look like a key button's
 kbd {
padding: .1em .6em;
border: 1px solid #ccc;
font-size: 10px!important;
font-family: Arial,Helvetica,sans-serif;
background-color: #f7f7f7;
color: #333;
-moz-box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;
-webkit-box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;box-shadow: 0 1px 0 rgba(0,0,0,0.2),0 0 0 2px #fff inset;border-radius: 3px;
display: inline-block;
margin: 0 .1em;
text-shadow: 0 1px 0 #fff;
line-height: 1.4;
white-space: nowrap;
}
Example:
<kbd>ctrl</kbd>+<kbd>p</kbd>

ctrl+p

That looks better.