Print Stylesheet CSS : Blogging Tips |
What is print style sheet or print.css ?
Its a special CSS defined for a website by using which the reader can print it's particular webpage very clearly without exceeding more paper & ink.Advantages :
- Increase usability & accessibility: A reader/student can print it and use it for later references.
- Decrease page loading: Still there are lots of visitors are on slow dial-up internet connection, who immediately go for printable version so that they have relevant information more quickly because such a slow internet connection causes very slow page loading to review the it online.
Disadvantage:
It increases page size for loading after adding this new CSS or if you add hyper-link then it one more request will add to you page loading.How to view & debug print style sheet
Before you go, check the print preview of you current blog post page. And also check the print preview of this page.- For Firefox : Menu Bar >> File >> Print Preview
- For Chrome : Right click on page >> Inspect element >> find setting button at right-bottom-corner >> check - Emulate CSS media.
How to build : print.css
Its really simple as that of we built the CSS for mobile template. You just need to know which part should be printed and which part should NOT be printed.Lets Start
To start the making of print CSS, a special CSS-tag @media print is used to tell the browser that the current page is going to be printed.@media print {
... ... ...
...user defined other tags...
... ... ...
}
... ... ...
...user defined other tags...
... ... ...
}
Now list the parts of your page you dont want to print like menu, navigation, sidebar etc and place it in above mentioned tag like
@media print {
#menu, #nav, #sidebar, #sidebar-wrapper { display:none}
}
#menu, #nav, #sidebar, #sidebar-wrapper { display:none}
}
Make main wrapper content to full width:
#main-wrapper {width: 100%; margin: 0; float: none; }
Remove the background:
body { background: white; }
#container { background: transparent;}
#container { background: transparent;}
Set font style and size
body { font:normal 14px Georgia, "Times New Roman", Times, serif; line-height: 1.5em; color: #222; }
Differentiate links and text
a:link { font-weight: bold; text-decoration: underline; color: #000; }
Print URL after links
a:link:after { content: " (" attr(href) ") "; }
Show Thank You message for a reader
body:after { display: block; content: "Thank you for printing our content."; margin-top: 30px; font-size: 11pt; color:#555; border-top: 1px dotted #555; }
Define page margin
@page { margin: 0.5cm; }
Final print stylesheet CSS
@media print {
#menu, #nav, #sidebar, #sidebar-wrapper { display:none}
#main-wrapper {width: 100%; margin: 0; float: none; }
body { background: white; }
body { font:normal 14px Georgia, "Times New Roman", Times, serif; line-height: 1.5em; color: #222; }
#container { background: transparent;}
@page { margin: 0.5cm; }
a:link { font-weight: bold; text-decoration: underline; color: #000; }
a:link:after { content: " (" attr(href) ") "; }
body:after { display: block; content: "Thank you for printing our content."; margin-top: 30px; font-size: 11pt; color:#555; border-top: 1px dotted #555; }
.noprint { display:none }
}
#menu, #nav, #sidebar, #sidebar-wrapper { display:none}
#main-wrapper {width: 100%; margin: 0; float: none; }
body { background: white; }
body { font:normal 14px Georgia, "Times New Roman", Times, serif; line-height: 1.5em; color: #222; }
#container { background: transparent;}
@page { margin: 0.5cm; }
a:link { font-weight: bold; text-decoration: underline; color: #000; }
a:link:after { content: " (" attr(href) ") "; }
body:after { display: block; content: "Thank you for printing our content."; margin-top: 30px; font-size: 11pt; color:#555; border-top: 1px dotted #555; }
.noprint { display:none }
}
Above sample is just for learning purpose. For every blogger there is different style sheet for each.
Avoid extra stuff to be printed
In above example if you observe, you will get notice the CSS code .noprint. While I was working on this I notice some widgets are still get printed and its really unwanted and annoying on paper. So special CSS class is defined to avoid that extra stuff from paper. What you need to to is just put your unwanted html code as;<span class='noprint'>
...your unwanted extra stuff...
</span>
And define that class do display: none in stylesheet CSS....your unwanted extra stuff...
</span>
- More: you can use this CSS code in cascading to your regular blogger CSS before <skin> tag or if you want you can also use following hyperlink as per your convenience <!-- Print Stylesheet CSS -->
<link rel="stylesheet" href="URL to your print.css" type="text/css" media="print" />
EmoticonEmoticon