Until recently, I always had trouble figuring out the best way to format code snippets I wanted to post on my blog. I had trouble with losing the whitespace, lines of code being too long for the page, or the formatting would just plain suck. I’ve found the best solution is to place code within the following:

<pre style=”width:500px;height:400px;border:solid 1px #ccc;overflow:scroll;”>
paste code here
</pre>

This will create a nice little border around your code, along with scroll bars, AND preserve the whitespace. This solution brought to you by the wordpress forums.