HTML - Code element


The code element represents a fragment of computer code.

By default, the content text is displayed using the user agent's default monospace font.


The following example shows how the element can be used in a paragraph to mark up element names and computer code, including punctuation.

<p>The <code>code<code> element represents a fragment of computer

<p>When you call the <code>activate()<code> method on the
<code>robotSnowman<code> object, the eyes glow.</p>

<p>The example below uses the <code>begin<code> keyword to indicate
the start of a statement block. It is paired with an <code>end<code>
keyword, which is followed by the <code>.<code> punctuation character
(full stop) to indicate the end of the program.</p>

The following example shows how a block of code could be marked up using the pre and code elements.

<pre><code class="language-pascal">var i: Integer;
   i := 1;

A class is used in that example to indicate the language used.

Prettifying / Syntax Highlighting

Prettifying can be done by the client through JavaScript library:

Documentation / Reference

Discover More
HTML - (Flow|Body) Content

Most elements that are used in the body of documents and applications are categorized as flow content. Flow content consists of flow elements intermixed with normal character data. (ifbodhead...
HTML - Document

An HTML document is a well-formed HTML string (ie that contains the html root element). web page The HTML textual representation can be stored: in a string in a file or in the body of an HTTP...
HTML - Palpable content

As a general rule, elements whose content model allows any flow content or phrasing content should have at least one node in its contents: that is palpable content (Can be manipulated ?) and that...
HTML - Phrasing Content (Text)

Phrasing content is: the text of the document, as well as elements that mark up that text at the intra-paragraph level. Runs of phrasing content form paragraphs. Most elements that are categorized...
Lexical Mode / Lexer Context

The lexical mode is a lexer property while creating the token. It's also known as: lexer context or lexer state This is generally the only context related data. It permits to apply lexer rules...

Share this page:
Follow us:
Task Runner