Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

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

like image 259
Kevin Li Avatar asked Sep 08 '09 15:09

Kevin Li


Video Answer


2 Answers

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

like image 61
knittl Avatar answered Nov 05 '22 18:11

knittl


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

like image 25
Jonathan Patt Avatar answered Nov 05 '22 19:11

Jonathan Patt