HTML usually employs variable letter spacing and size.

However, this is not required for displaying the examples of computer code.

<samp, <kbd> and <code> gives support to fixed letter spacing and size.

HTML Keyboard Input

<kbd> element is used for defining the keyboard input

Syntax
<kbd>Technology|Diving...</kbd>
Output
Technology|Diving...

HTML for Computer Output

<samp> element is used for defining the sample output of a computer code or program.

Syntax
<samp>
Technology Diving, April 2016
</samp>
Output
Technology Diving, April 2016

HTML Computer Code

<code> element is used for defining the piece of programming code.

Syntax
<code>
var a=2;
var b=5;
document.getElementById(“demo”).innetHTML=a+b;
</code>

It is a noteworthy fact that <code> element does not consume any extra line-breaks and whitespace.

In order to fix this, <code> element can be used within <pre> element.

Syntax
<pre>
<code>
var a=2;
var b=5;
document.getElementById(“demo”).innetHTML=a+b;
</code>
Output
var a=2;
var b=5;
document.getElementById(“demo”).innetHTML=a+b;

HTML For Variables

<var> element is used for defining a variable.

The variable to be defined could be the variable in a mathematical expression or programming code.

Syntax
<var>b</var>=<var>a</var><var>c</var>
Output:
b=ac
Do a quick revision:
<kbd>           Defines keyboard input
<samp>        Defines computer output
<code>         Defines programming code
<pre>            Defines preformatted content
<var>            Defines a variable
email