CSS

HTML ComputerCode


HTML Computer Code Formatting HTML normally uses variable letter size and spacing. This is not wanted when displaying examples of computer code. The <kbd>, <samp>, and <code> elements all support fixed letter size and spacing. HTML <samp> For Computer Output The HTML <samp> element defines sample output from a computer program: Example <samp> demo.example.com login: Apr 12 09:10:17 Linux 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189 </samp>


<!DOCTYPE html>
<html>
<body>

<p>The samp element represents sample output from a computer program:</p>

<samp>
demo.example.com login: Apr 12 09:10:17
Linux 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189
</samp>

</body>
</html>

Output :
demo.example.com login: Apr 12 09:10:17 Linux 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189 

HTML <code> For Computer Code The HTML <code> element defines a piece of programming code: Example

<code>
var x = 5;
var y = 6;
document.getElementById("demo").innerHTML = x + y;
</code>

Output:
var x = 5; var y = 6; document.getElementById("demo").innerHTML = x + y

HTML <var> For Variables The HTML <var> element defines a variable. The variable could be a variable in a mathematical expression or a variable in programming context: Example

Einstein wrote: <var>E</var> = <var>m</var><var>c</var><sup>2</sup>.

Output:
Einstein wrote: E = mc2.