Use the proper markup to make the code monospaced and keep whitespace as-is. This basically means using <pre>
and <code>
:
<pre><code>
your();
code = "here";
</code></pre>
After that you just need to add some nice CSS styling to make it look nice. And if you want syntax highlighting like here on Stack Overflow simply the easiest way to get it is adding google’s prettify: http://code.google.com/p/google-code-prettify/
3
solved How to display code blocks in my private blog [closed]