Friday, August 20, 2010

Posting HTML Code on webpage

From time to time, some blogger or developer want to post their HTML code on their website. However this task doesn't seem to be as direct as it sounds. To illustrate the problem, here is an example, if I want to post this HTML code,

<form>
<textarea name="comments" cols="50" rows="2">This is a textarea within a form</textarea>
</form>

The HTML code is interpreted and rendered into the form result.


Therefore, in order to display the actual HTML code, place the HTML code within <code> tags like <code>..</code>

<code>
<form>
<textarea name="comments" cols="50" rows="2">This is a textarea within a form</textarea>
</form>
</code>

In addition, the code within the code tag need to have its HTML cleaned from < and >. The < sign need to be replaced by &lt; and > need to be replaced by &gt; To make it easy, you could use this side to convert the code for you by simply pasting your code on this site http://www.simplebits.com/cgi-bin/simplecode.pl?mode=process

No comments:

Post a Comment