Tuesday, March 17, 2009

Display HTML code in HTML web page

To display HTML code in a HTML page, you need first to replace "<" and ">" with "&lt;" and "&gt;", then add <pre></pre> around them. Here is an example:

To display the following in a HTML page

<h2>Header</h2>

<p>This is my HTML code</p>

You actually have the following text in your HTML page

<pre>&lt;h2&gt;Header&lt;/h2&gt;

&lt;p&gt;This is my HTML code&lt;/p&gt;</pre>

No comments:

Post a Comment