<codeblock>

A code block is a set of lines from a program.

Rendering expectations

Processors SHOULD preserve line the breaks and spaces that are present in the content of a <codeblock> element.

The content of the <codeblock> element is typically rendered in a monospaced font.

Specialization hierarchy

The <codeblock> element is specialized from <pre>. It is defined in the programming domain module.

Content model

(Text | <cite> | <include> | <keyword> | <markupname> | <apiname> | <option> | <parmname> | <cmdname> | <msgnum> | <varname> | <wintitle> | <numcharref> | <parameterentity> | <textentity> | <xmlatt> | <xmlelement> | <xmlnsname> | <xmlpi> | <ph> | <strong> | <em> | <b> | <i> | <line-through> | <overline> | <sup> | <sub> | <tt> | <u> | <hwcontrol> | <partno> | <codeph> | <filepath> | <msgph> | <systemoutput> | <userinput> | <synph> | <menucascade> | <uicontrol> | <q> | <term> | <abbreviated-form> | <text> | <xref> | <state> | <coderef> | <data> | <sort-as> | <foreign> | <unknown> | <draft-comment> | <fn> | <indexterm> | <required-cleanup> )*

Attributes

The following attributes are available on this element: display attributes, universal attributes, and @xml:space.

Example

The following code sample shows how the <codeblock> element can be used to tag an excerpt from an XSLT stylesheet:

<codeblock>
  &lt;xsl:template match="*[contains(@outputclass,'green')]">
    &lt;xsl:attribute name="color">#006400;&lt;/xsl:attribute>
  &lt;/xsl:template>
</codeblock>

For a sample of how this element can be combined with <coderef> to embed external code samples, see coderef.