If u want code samples to be syntax-highlighted on your blog. Pure CSS would not work, unless the code samples were completely messed up with
The coding is very simple
Source :
http://jroller.com/dschneller/entry/google_code_prettify
http://binkley.blogspot.com/2007/04/googles-excellent-code-coloring.html
span
s and div
s to indicate which style to apply to every word, number or punctuation.If u want something like this, where some part of the code needs to be highlighted ....
You can opt for google code prettify
The coding is very simple
<html> | |
<head> | |
<title>Example</title> | |
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet" /> | |
<script type="text/javascript" src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script> | |
</head> | |
<body onload="prettyPrint()"> | |
<h1>C</h1> | |
<pre class="prettyprint">void | |
main(char* argv[]) | |
{ | |
printf("Hello, Bob.\n"); | |
}</pre> | |
<h1>Java</h1> | |
<pre class="prettyprint">public class Main { | |
public static void main(final String[] args) { | |
System.out.println("Hello, Bob."); | |
} | |
}</pre> | |
<h1>Shell</h1> | |
<pre class="prettyprint">echo "Hello, Bob."</pre> | |
</body> | |
</html> |
Source :
http://jroller.com/dschneller/entry/google_code_prettify
http://binkley.blogspot.com/2007/04/googles-excellent-code-coloring.html