Skip to content Skip to sidebar Skip to footer

How Do I Display Html Code (entities) On A Web Page?

how do you write html code so the user and see it on a webpage (like a how-to for html)

Solution 1:

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

Solution 2:

You have to use HTML character entities &lt; and &gt; in place of the < and > symbols so they aren't interpreted as HTML tags.

Solution 3:

To avoid issues with &apos;, use &#39;.

Post a Comment for "How Do I Display Html Code (entities) On A Web Page?"