How do I display HTML code (entities) on a web page?

encode your html entities:

< … &lt;
> … &gt;
& … &amp;
" … &quot;
(' … &apos; xml, not html. see comments)

you might also want to use

<pre><code>
here comes your preformatted and escaped &lt;html&gt;-code
</code></pre>

to have your code monospaced and preserve whitespaces

Leave a Comment