HTML-Elemente für Computercode
Der Computer verwendet ein spezielles Format und einen Textstil zur Anzeige von Nachrichten, die mit Codes verbunden sind. In HTML gibt es verschiedene Elemente für Computercode.
Das HTML <code>-Tag
Das HTML <code>-Tag fügt Fragmente von Programmcode, Variablen usw. in ein HTML-Dokument ein. Im Browser wird der Code in einer kleineren Schrift mit fester Breite angezeigt.
Beispiel für das HTML <code>-Tag:
Beispiel für das HTML <code>-Tag
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>This is an ordinary text.</p>
<code>This is a program code.</code>
<p>This is the continuation of the ordinary text.</p>
</body>
</html>Das HTML <var>-Tag:
Das <var>-Tag definiert eine Variable in einem mathematischen Ausdruck oder einem Programmierkontext.
Beispiel für das HTML <var>-Tag:
Beispiel für das HTML <var>-Tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p><var>x</var> = <var>y</var> + 5</p>
</body>
</html>Das HTML <kbd>-Tag:
Das <kbd>-Tag gibt eine Tastatureingabe an. Es wird verwendet, wenn Text angezeigt werden soll, der über die Tastatur des Benutzers eingegeben werden muss.
Beispiel für das HTML <kbd>-Tag:
Beispiel für das HTML <kbd>-Tag
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h2>The kbd example</h2>
<p>You can paste the document by pressing <kbd>Ctrl + V</kbd>.</p>
</body>
</html>Das HTML <samp>-Tag
Das <samp>-Tag enthält die Ausgabe eines Computerprogramms oder Skripts. Standardmäßig wird es in einer Schrift mit fester Breite angezeigt.
Beispiel für das HTML <samp>-Tag:
Beispiel für das HTML <samp>-Tag:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p>This is an ordinary text. <samp>But this is a sample text.</samp> Here is another ordinary text.</p>
</body>
</html>Practice
Welche Tags werden in HTML verwendet, um Computercode anzuzeigen?