HTML - Code element

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - About

The code element represents a fragment of computer code.

Advertising

3 - Example

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
code.</p>
 
<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;
begin
   i := 1;
end.<code></pre>

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

4 - Prettifying / Syntax Highlighting

Prettifying can be done by the client through JavaScript library:

5 - Documentation / Reference

web/html/code.txt · Last modified: 2019/02/09 11:29 by gerardnico