Code elements in HTML
Code elements in HTML:
If you want to write something like coding then you must go through the <code> tag in HTML, which provides the facility to code as it is. <code> element is used to write some computer code i.e. content shown in page by default monospace font.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Computer Code</h2>
<p>Hello folks:</p>
<code>
x = 2;
y = 3;
z = x + y;
</code>
</body>
</html>
<var> in HTML:
In order to define the variables in programming or a mathematical expression, then you must go with this tag. By default, it must go with an italic font.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Here var Element will be detailed</h2>
<p>To add two numbers: <var>a+b</var> </var>, where <var>a</var> is 2, and <var>b</var> is 2.</p>
</body>
</html>
<kbd> tag in HTML:
If you wish to add a message to add and define keyboard input, then you can go with the <kbd> element.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>kbd tag</h2>
<p>Print the document by pressing <kbd>Ctrl + P</kbd></p>
</body>
</html>
<samp> in HTML:
<samp> is used to define the output from a computer program on a webpage. Default they have the monospace font.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>The samp Element</h2>
<p><samp>Screen is hanged.<br>Press ctrl+alt+del to continue</samp></p>
</body>
</html>
