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 display="block" id="popup">
   function popUp() {
       var popmsg = 'Hello &amp; goodbye';
       alert($popmsg);
   }
</code>
        

Results in this display:

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?)

label (one, optional), title (one, optional), term, cite, cite-title, foreign, emphasis, sub, sup, code, preformat, quote, note, list, media, footnote, link, newline, space, caption, Unicode text

Parents(what's this?)

title (one, optional), label (one, optional), preformat, para, cite-title, cite, link, emphasis, term, sub, sup, quote, foreign, footnote, note, item, code, figure, subfigure, caption, commentary, meaning, entry, content, section, example, problem, solution, statement, proof, audio, flash, video, text, java-applet, image, labview, download
Close this window