Usage of page-break-before, page-break-after, and page-break-inside properties in CSS



Suppose your document has level-1 headers start new chapters with level-2 headers to denote sections. You'd like each chapter to start on a new, right-hand page, but you don't want section headers to be split across a page break from the subsequent content. You can achieve this using following rule −

<style>
   <!--
      h1 { page-break-before : right }
      h2 { page-break-after : avoid }
   -->
</style>

Use only the auto and avoid values with the page-break-inside property. If you prefer that your tables not be broken across pages if possible, you would write the rule −

<style>
   <!--
      table { page-break-inside : avoid }
   -->
</style>
Samual Sam
Samual Sam

Learning faster. Every day.


Advertisements