How to apply CSS page-break to print a table with lots of rows?

Mohammad Saberi picture Mohammad Saberi · Jan 3, 2012 · Viewed 219.5k times · Source

I have a dynamic table in my web page that sometimes contains lots of rows. I know there are page-break-before and page-break-after CSS properties. Where do I put them in my code in order to force page breaking if needed?

Answer

Hemant Metalia picture Hemant Metalia · Jan 3, 2012

You can use the following:

<style type="text/css">
   table { page-break-inside:auto }
   tr    { page-break-inside:avoid; page-break-after:auto }
</style>

Refer the W3C's CSS Print Profile specification for details.

And also refer the Salesforce developer forums.