Is there any css code for browsers to print out background colors? No, there is no such css code, background images and colors are ignored for browsers. So don't rely on background colors for printing.
To let browsers print background colors and images, you need to configure your browsers option.
For Firefox, go to File->Page Setup->Enable Print Background option.
For IE, go to Tools->Internet Options->Advanced->Enable Print background colors and images option.
<pre><code> String foo = "bar"; </code></pre>