Nov 23, 2011

How to create a scroll box containing code in blogger

Many a times bloggers try to insert code in their blogs but end up consuming huge chunks of space in their post with codes. A better solution is to combine and confine them in a special text box.


First thing you have to know is that if you try to type the HTML as it is (example <br />), the browser will interpret that as an instruction to display what follows in a new line (line break) but not display the HTML.


There are three approaches to this.

1. > Remove < and > and replace them with '&lt' and '&gt' in the code you want to insert.

2. > Go to http://centricle.com/tools/html-entities/
       paste the HTML codes in between <em></em> and click "encode", then proceed as usual.

3. > Another better option is using codewiz at http://gens.codezwiz.com/


 Here is a sample of how it will look like after its done.

<div style="width: 395px; height: 400px; background-color: a0ffff;
color: 000000; font-family: arial; font-size: 12px; text-align: left; border: 0px solid 00000; overflow: auto; padding: 4px;"></div>

Article Number UAN#026CMKT