3.11.1. Avoiding Page Breaks within Blocks

For the following elements a flag can be set that suppresses the insertion of page-breaks within the element:
  • div
  • p
  • pre
  • table
The flag is set by adding the name "keep_together" to the list of CSS classes supplied in the class attribute. Example:
<div class="note keep_together"> ... </div>
If the flag is set and the remaining space on the page is less than the height of the element, then the element is moved to the next page. Be aware, that if page breaks are suppressed for an element, then it has to be assured that the element fits completely on one page. Otherwise the element flows into the footer of the page and content may be cut off at the bottom of the page.
Alternatively, the flag can also be set through the style attribute, by adding the pseudo CSS property "keep-together:always". That means, the example above could also be written as:
<div class="note" style="keep-together:always;"> ... </div>
However, it is recommended to use the class attribute instead of the style attribute, because the property "keep-together:always" is no standardized CSS property, which may be detected as warnings when the content is checked for HTML conformity.