HTML Computer Code

HTML Tutorial

HTML Forms

HTML Graphics

HTML Media

HTML API

HTML Computer Code Elements

HTML consists of several elements for defining user input and computer code.

Example

				
					<h2>Computer Code</h2>
<p>Some programming code:</p>
<code>
x = 5;
y = 6;
z = x + y;
</code>

				
			

Output:

Computer Code

Some programming code: x = 5; y = 6; z = x + y;

HTML <var> For Variables

The HTML <var> element defines a variable in programming or in a mathematical expression. The content within is typically showed in italic.

Example

				
					<p>The area of a triangle is: 1/2 x <var>b</var> x <var>h</var>, where <var>b</var> is the base, and <var>h</var> is the vertical height.</p>

				
			

Output:

The area of a triangle is: 1/2 x b x h, where b is the base, and h is the vertical height.

HTML <kbd> For Keyboard Input

The HTML <kbd> element defines the keyboard input. The content within is showed in the browser’s default monospace font.

Example

				
					<p>The kbd element is used to define keyboard input:</p>
<p>Save the document by pressing <kbd>Ctrl + S</kbd></p>


				
			

Output:

The kbd element is used to define keyboard input:

Save the document by pressing Ctrl + S

HTML <samp> For Program Output

The HTML <samp> element defines sample output from a computer program.

Example

				
					<p>Message from my computer:</p>
<p><samp>File not found.<br>Press F1 to continue</samp></p>



				
			

Output:

Message from my computer:

File not found.
Press F1 to continue


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420