-5

I want to display code blocks in my private blogging site. I am creating it from the scratch. How to proceed with it. I am totally confused.

Abhishek Prakash
  • 964
  • 2
  • 10
  • 24

2 Answers2

0

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/

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • Thanks..But I want to display the code like this site: https://developer.mozilla.org/en-US/docs/DOM/Using_web_workers I need color highlighting and indentation as well. – Abhishek Prakash Dec 25 '12 at 13:59
  • Did you actually *read* my answer? Indentation is done by yourself and preserved by using `
    ` tags. For highlighting I've linked you to something that's even used here on SO.
    – ThiefMaster Dec 25 '12 at 14:27
  • ya it got updated after i posted the comment. Thanks :) – Abhishek Prakash Dec 25 '12 at 14:29
0

Try Syntax Highlighter. Its easy and looks really good.
Demo Link

Ajinkya
  • 22,324
  • 33
  • 110
  • 161