Sunday, 20 April 2014

How to Display HTML code on a Blogger blog post

The seemingly simple task of showing someone a string of HTML or JavaScript code to use on their blog/web site can be a challenge because the blog compiler interprets the string to be displayed on the page as something it should process and turn into a web function.

One way around this is to enclose the code in a <textarea> 

To do this in Blogger, switch to the HTML view of your post and find where you want to display the code snippet.
insert a <textarea cols="70" rows="1"> tag followed by your code string and completed by the </textarea> tag so your post looks like this ...

Another way is to replace all actual < and > characters with their ASCII code equivalents &#60 ; and &#62 ; or &lt ; and &gt ; so your post looks like this ...

No comments: