Close this window

Using the <code> tag

Description The code tag is used to insert a line or block of computer code (for example a command) into a document.
Example
This CNXML:
<para id="codeexample">
  Enter the command <code>ls /etc</code> to
  get a listing of configuration files.
</para>
	
Results in this display:
Enter the command ls /etc to get a listing of configuration files.
Example
This CNXML:
<code type="block">
    function popUp() {
        var popmsg = 'Hello &amp; goodbye';
        alert($popmsg);
    }
</code>
	
Results in this display:
    function popUp() {
        var popmsg = 'Hello & goodbye';
        alert($popmsg);
    }
Note that ampersand and angle bracket characters (&, <, and >) must be escaped (what's this?). Their escaped equivalents are &amp;, &lt;, and &gt;, respectively. Alternatively, one can insert <![CDATA[ before the code text and ]]> after it (what's this?) to eliminate the need for escaping.
Attributes (what's this?)
Children (what's this?)emphasis, code, term, cite, cnxn, link, foreign, quote, Unicode text
Parents (what's this?)figure, subfigure, para, meaning, note, item, caption, entry, emphasis, code, term, cite, cnxn, link, foreign, quote, content, section, example, meaning, proof, statement, problem, solution
Close this window