What are the most useful media="print"
-specific, cross-browser-compatible CSS properties?
I think we have these 5 properties for print specific.
- page-break-before
- page-break-after
- page-break-inside
- widows
- orphans
Please explain when and where to use these? Which are cross browser compatible? and what are other common CSS properties can be useful in print, other than display:none
?
I use the following:
I use the famous A list apart article (CSS Design: Going to Print) and this article when I need to make a printable version of a page. There are some common tags, but a lot depends on the css model (as well as container padding and margins) you are using:
Chris Coyier at css-tricks.com wrote a great article on this: http://css-tricks.com/css-tricks-finally-gets-a-print-stylesheet/
In the spirit of sharing, here's a couple of rules I regularly use. They fit in well with SemanticUI, but may be helpful elsewhere
Display on screen and print
Use
class="printed"
. This is handy when you have tabs in your UI, so you can force them to be printed even if they aren't currently being displayedDisplay on screen but don't print
Use
class="non printed"
. This is handy for navigation elements and other stuff you don't want to printDon't display on screen but print
Use
class="printed only"
. I find it handy to include some metadata about a webpage on the printed version that might be irrelevant to the web version - eg the date/time the page was generated, the username of the person that printed the document, a link (if removed from headers) and soforth.