W3.CSS Code
Displaying Examples
The w3-example class is designed to display examples in a grey container:
Displaying Code
The w3-code class is designed for displaying code.
It displays code with a well readable monospaced font.
Example
fruits[0] = "Banana";
fruits[1] = "Apple";
fruits[2] = "Mango";
fruits[3] = "Plum";
Code Coloring
W3Schools provides a JavaScript library for coloring code.
Example
fruits[0] = "Banana";
fruits[1] = "Apple";
fruits[2] = "Mango";
fruits[3] = "Plum";
You can download the library from here: http://www.w3schools.com/lib/w3codecolor.js