HTML Computercode:




The code element

The element CODE is used for computer code. This element that is CODE is used to format the text in monospace. A monospace font is also called fixed pitch. This is a font in which all the letters and the characters take an equal amount of horizontal space. A white space usually represents a horizontal space. To understand the use of CODE element, we first have to understand PRE element.




The code element is used to make a selection of the computer code that is typed for example a single line of the program code. The code element is used as follows:

<p> This is a paragraph.

<code>It contains a code</code></p>

code

The large codes should be displayed using the PRE element that reduces the space characters and the line breaks. The contents that are written in the CODE element should be in a fixed width typewriter font. The code element can have characters, character highlighting, A, BR and IMG elements meaning that these elements can be written inside a code element. But the code element can be inside A, ADDRESS, character highlighting, PRE, Hn, P, DD, DT, LI elements. These will be discussed later.


The pre element

The pre element is used to display characters using a fixed width typewriter font. This element is used for the text that is not formatted yet or the preformatted text. This also preserves the spaces or space characters and carriage returns that are typed in the HTML document. The Pre element is used to display the computer codes and text because it encloses the text that is not formatted.

The pre element is also used to create or display tables in an HTML document as it preserves the horizontal spacing for the alignment of the text written in the HTML document.

It is used as follows:

<p> This is a paragraph.

<pre>It is about health care</pre></p>

pre




By using the PRE element we can also include the character emphasis that is we can use STRONG and EM elements to emphasis the text strings. To vertically align the text we use tags to highlight the anchors or the hyper text anchors as the tags cannot add width to the text.

The only elements that are allowed to use with the PRE element in HTML are Anchors and text highlighting elements. There are other elements that cannot be used with the PRE element in HTML; such elements include heading elements, paragraph elements, list elements, blockquote (used to add quotations), and the address elements. These elements are prohibited in HTML to be used with the PRE element.

The pre element can have characters, character highlighting and anchors (A). The pre element can be placed inside body, and blockquote element. This element takes WIDTH attribute that is used to specify the number of characters that are to be displayed in a single line.

The pre element is the only element in HTML that displays the data that should be in tables and columns.


The KBD element

The KBD element is used to input from the keyboard or the keyboard input. This element a text or block of text as the keyboard input. The KBD element can contain characters, character highlighting, A, BR and IMG elements inside itself. But the KBD element does not have any attributes.

<p> This is a paragraph.

<kbd>It is about health care</kbd></p>

pre


The SAMP Element

This element is used to mark a text or block of text as the sequence of sample or literal characters. The SAMP element provides a fixed width typewriter font. The SAMP element is also the literal character. The elements that can be packed inside the SAMP element are: characters, character highlighting, A, BR, and IMG. The SAMP element can be inside character highlighting element, address element, Hn, P, PRE, DD, DT, and LI elements and the SAMP element does not contain attributes.




It is used as follows:

<p> This is a paragraph.

<samp>Samp element provides typewriter font</samp></p>

samp