How to print code on HTML

You need to use character references instead of the plain characters themselves:

<code>&lt;HTML&gt;</code>

The elements code and pre are just to mark the content as code or preformated.


The <xmp> tag doesn't require the contents to be escaped.

eg:

<xmp>
    <p>Blah &nbsp;</p>
</xmp>

...will look like this on your screen:

    <p>Blah &nbsp;</p>

By escaping them.
&amp; will print &
&lt; will print >

You didn't mention what you're using to generate the html, if you're manually editing, some editors have options to escape a selection. If you're using a language, look for some function that escapes html special characters. (google for how to escape html in language-name-here)

Tags:

Html