HTML Computer Code Elements

in #computercode7 years ago (edited)

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

Sort:  

This post has received a 0.34 % upvote from @drotto thanks to: @rabiul21.

tomar post guli serial onujai hoai khub valo lage

Coin Marketplace

STEEM 0.21
TRX 0.26
JST 0.040
BTC 101120.17
ETH 3683.12
USDT 1.00
SBD 3.16