HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Define some text as keyboard input in a document
The <kbd>
tag is used to define keyboard input.
The content inside is displayed in the browser's default monospace font.
Also look at:
Tag | Description |
---|---|
<code> | Defines a piece of computer code |
<samp> | Defines sample output from a computer program |
<var> | Defines a variable |
<pre> | Defines preformatted text |
Element | |||||
---|---|---|---|---|---|
<kbd> | Yes | Yes | Yes | Yes | Yes |
The <kbd>
tag also supports the Global Attributes in HTML.
The <kbd>
tag also supports the Event Attributes in HTML.
Use CSS to style the <kbd> element:
<html>
<head>
<style>
kbd {
border-radius: 2px;
padding: 2px;
border: 1px solid black;
}
</style>
</head>
<body>
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text
(Windows).</p>
<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac
OS).</p>
</body>
</html>
HTML tutorial: HTML Text Formatting
HTML DOM reference: Kbd Object
Most browsers will display the <kbd>
element with the following default values:
kbd {
font-family: monospace;
}