February 1, 2000 - Page Breaks in Printing | WebReference

February 1, 2000 - Page Breaks in Printing

Yehuda Shiran January 31, 2000
Page Breaks in Printing
Tips: February 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

In order to insert page breaks when the document is printed, you need to use the page-break-before and page-break-after CSS styles. These styles only work with the following block elements: BLOCKQUOTE, BODY, CENTER, DD, DIR, DIV, DL, DT, FIELDSET, FORM, Hn, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, UL, and XMP. Here is an example that works with the P tag:

<HTML>
<HEAD><TITLE>Dynamic Styles: Page Breaking</TITLE>
<STYLE>
  P.page {page-break-after: always}
</STYLE>
</HEAD>
<BODY>
<P CLASS=page>
    .
  content on page 1
    .
</P>
    .
  content on page 2
    .
    .
</P>
</BODY>
</HTML>

Learn more about printing Web pages in our tip from October 29, 1999.