Md Robiul Islam avatar

HTML Computer Code Elements

rabiul21

Published: 25 May 2018 › Updated: 25 May 2018HTML Computer Code Elements

HTML Computer Code Elements

unnamed (1).png
source

HTML Computer Code Elements

Computer Code

<code>

x = 5; <br>

y = 6; <br>

z = x + y;

</code>

HTML <kbd> for keyboard input

The HTML <kbd> element represent users input, like keyboard input or voice command.

Text surrounded by <kbd> tags is typically displayed in the browser's default monospace font:

Example

<p>Save the document by pressing <kbd>Ctrl + s</kbd></p>

Result:

Save the document by pressing Ctrl + s

HTML <code> For Computer Code

The HTML <code> element defines a fragment of computer code

Example

<code>

x = 5;

y = 6;

z = x + y;

</code>

Result:

x = 5; y = 6; z = x + y;

Notice: that the <code> element does not preserves extra whitespace and line-break.

To fix this, you can put the <code> element inside a <pre> elements:

Example

<pre>

<code>

x = 5;

y = 6;

z = x + y;

</code>

</pre>

Result:

x = 5; y = 6; z = x + y;

HTML <samp> For Program Output

The HTML <samp> element represent outputs from a program or computing systems.

Example

<p>If you input wrong value, the program will return <samp>Error!</samp></p>

Result:

If you input wrong value, the program will return Error!

HTML <var> For Variables

The HTML <var> elements define a variables.

The variable could be a variable in a mathematicals expression or a variable in programmings context:

Example

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

Result:

Einstein wrote: E = mc2

Leave HTML Computer Code Elements to:

Written by

I am a Web design and Developer

Read more #computercode posts


Best Posts From Md Robiul Islam

We have not curated any of rabiul21's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Md Robiul Islam