Saturday, April 18, 2009

How to include HTML code in a blogger blog post

I noticed that posting html tags (specially misformed ones)
results in the blogger throwing an error or displays the
content wrongly.

There are two alternatives to resolve this issue -

1. The simple approach - It is easy to use this approach
if the lines of html code you want to put on your post are small.
The only thing that needs to be taken care of is the following
substitution - replace all less than, greater than signs that
are part of html tags with &ltsemi-colon and &gtsemi-colon.

E.g. Consider the following line of html code
<img alt="Photo" src="http://URL_to_my_image.gif" />

would be written as -
&ltsemi-colonimg alt="Photo" src="http://URL_to_my_image.gif" /&gtsemi-colon

in your post to show up correctly on the post.

Note in all of the above cases please replace the semi-colon with ;
I am not able to include the actual symbol as a single string since it
shows up as a < in my post.

2. The second approach - relies on using html framing.
You can edit the code in a way to include your html page as
a frame in the post. This is specially useful if you are posting
a large peice of html code.

Hope this works for you. If it does not, please feel free to post
comments.

0 comments:

Post a Comment