HTML <kbd> Tag
Definition und Verwendung
<kbd>
Das Tag wird verwendet, um Tastatureingaben zu definieren. Der Inhalt wird in der Standard-Darstellung der Schriftart des Browsers angezeigt.
Tipp:Dieser Tag ist nicht abgekündigt. Allerdings können durch die Verwendung von CSS umfangreichere Effekte erzielt werden (siehe untenes Beispiel).
Weitere Informationen:
Tag | Beschreibung |
---|---|
<code> | Definieren Sie die Beispiel-Ausgabe eines Computersprogramms. |
<samp> | Definieren Sie Tastatureingaben. |
<var> | Definieren Sie Variablen. |
<pre> | Definieren Sie vorformatierten Text. |
Weitere Informationen:
HTML-Tutorial:HTML Text Formatting
HTML DOM Referenzhandbuch:Kbd-Objekt
Beispiel
Beispiel 1
Einige Texte im Dokument als Tastatureingabe definieren:
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy the text (Windows).</p> <p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy the text (Mac OS).</p>
Beispiel 2
Die CSS wird verwendet, um das Stilelement <kbd> zu setzen:
<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 the text (Windows).</p> <p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy the text (Mac OS).</p> </body> </html>
Global Attributes
<kbd>
The tag also supports Global Attributes in HTML.
event attributes
<kbd>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will display the following default values <kbd>
Element:
kbd { font-family: monospace; }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |