CodesCompiler
🔍
HTMLCSSJavaScriptPythonSQLPHPSEOPostsBooksKids About Contact 🚀 Get Started Free

HTML Computer Code Elements

HTML Computer Code Elements

HTML computer code elements (tags) provide unique formatting and text styles for different types of code-related messages, such as keyboard input, preformatted text, code snippets, variables, and sample outputs. The computer code elements are listed as follows:

  • <kbd> Element

  • <pre> Element

  • <code> Element

  • <var> Element

  • <samp> Element

HTML <kbd> Element

The <kbd> tag is used to define the keyboard input. Use this when you want the user to type on their keyboard, for example, shortcut keys Ctrl+C for copy, Esc for exit, etc.

Example

Let us now see an example to implement the <kbd> tag:

Preview

HTML <pre> Element

The <pre> tag in HTML is used to set preformatted text. The text preserves spaces and line breaks, appearing the same on the web page as in the HTML code.

Example

Let us now see an example to implement the <pre> tag:

Preview

HTML <code> Element

The <code> tag is used to format code in an HTML document. For example, to write and format Java code properly, use the <code> element.

Example

Let us now see an example to implement the <code> element:

Preview

HTML <var> Element

The <var> tag in HTML is used to display mathematical expressions for calculations.

Example

Let us now see an example to implement the <var> tag:

Preview

HTML <samp> Element

The <samp> tag is a phrase tag used to format text in an HTML document.

Example

Let us now see an example to implement the <samp> element:

Preview

HTML Computer Code Elements

Here is the list of the computer code tags along with their descriptions used for defining user input and computer code:

TagDescription
<kbd>Defines keyboard input.
<pre>Displays preformatted text with preserved spaces and line breaks.
<code>Defines a piece of computer code.
<var>Represents a variable in programming or math expressions.
<samp>Defines sample output from a program or device.