/    /  HTML Computer code

HTML Computer code

 

The programming language, sometimes it is mandatory to show the Output result, error message, or coding part to the user on a webpage. To solve this type of issue HTML uses different tags for the user inputs, codes, programs, form, etc.

 

 List of some tags  are used in HTML:

 

  • <code>
  • <kbd>
  • <samp>
  • <var>
  • <pre>

 

<code> element:

 

HTML <code> element used to represent some programming code on your website. The content is written inside is displayed in the default monospace font.

 

Example:

 

<!DOCTYPE html>
<html>
<body>
<h2>Computer Code</h2>
<code>
x = 7;<br>
y = 6;<br>
z = x + y;
</code>
</body>
</html>

 

OUTPUT:

 

HTML Computercode

 

<kbd> Element:

 

HTML <kbd> used to define user input, keyboard input, voice command, etc. Text written within <kbd>…..</kbd> tags is typically displayed in the browser’s default monospace font.

 

Example:

 

<!DOCTYPE html>
<html>
<body>
<h2>The kbd Element</h2>
<kbd>This is Content written within kbd element looks like.</kbd></p>
</body>
</html>

 

OUTPUT:

 

HTML Computercode

 

<samp> Element:

 

The HTML <samp> element is used to define a program’s output. Content written within the samp element is typically displayed in the browser’s default monospace font.

 

Example:

 

<!DOCTYPE html>
<html>
<body>
<h2>The samp Element</h2>
<samp>This is the content within samp element looks like. </samp>
</body>
</html>

 

OUTPUT:

 

HTML Computercode

 

<var> element:

 

The HTML <var> element is used to define a variable in programming. Variable in a mathematical expression or programming context.

 

Example:

 

<!DOCTYPE html>
<html>
<body>
<h2>The var Element</h2>
<p>This is a famous formula: <var>E</var> = <var>mc</var><sup>2</sup>.</p>
</body>
</html>

 

OUTPUT:

 

HTML Computercode

 

<pre> element:

 

The <pre> element defines the preformatted text, which displays the content within it in a fixed-width font. It keeps the content in its original format and ignores all formatting.

 

Example:

 

<!DOCTYPE html>
<html>
<body>
<h3>Example of pre tag</h3>
 <pre>
      This is content written
      within pre tag,
      spaces,     break lines, list of lines
      as in original format.
 </pre>
</body>
</html>

 

OUTPUT:

 

HTML Computercode