ל Page Breaks in HTML: A Solution! On January 18 I complained of the lack of a page break command in HTML. A reader very kindly told me of a quasi-HTML command that does this in my Mozilla browser and its inferior competitor, Internet Explorer. He referred me to Irt.Org (but note that the </div > part of the command specified there seems to be unnecessary, mere clutter). The command is as simple as this:


Here is where page one ends.

<div style="page-break-before:always">

Here is where page two starts and  ends.

<div style="page-break-before:always">

Here is where page three starts.


The <div style="page-break-before:always"> command is invisible to the viewer of your HTML page in a web browser. If he hits PRINT PREVIEW, however, he will see the page broken up into pages, and if he hits PRINT the file will print broken up into pages.

A caveat is that if you've put your page breaks in so that the page prints out prettily on your own computer, it might not print out so [prettily on someone else's computer which is using different fonts and margins. This is shown on the example of the file I used for the overhead slides for my regulation class yesterday,http://mypage.iu.edu/~erasmuse/g406/antitrust_laws.htm. That file uses the <big > <big > command to enlarge the font a couple of times, and then uses <div style="page-break-before:always"> to break the file up into 8x11 pages suitable for printing and converting to overhead projector slides. But it does that for Eric Rasmusen's Mozilla browser and HP printer. The page breaks are still there, in the same places, when I use my Internet Explorer browser, but the margins are bigger, so the breaks sometimes are at bad places. That's unavoidable for a page break command --Latex has the same problem-- so I'm overjoyed.

This probably should be added to the wonderful Bare Bones Guide to HTML. I'll let Mr. Werbach know.

UPDATE. Later on January 21, my expert source emailed me that:

You are correct that the </div> is not needed, however it is a good practice to put it in, as not closing your tags would make your HTML not be XHTML compliant. If you want, you can do it like this <div style... /> with the / in the same tag that opened it up. That makes it well formed xml/html

Also, there are other modifiers besides "always" that might make page breaks work more generically. In particular, the "auto" mode says "hey, here is a good spot to do a page break if you might need one soon, but if you don't need one, dont make one"

Here is a better description than the one I originally posted. http://www.w3schools.com/css/pr_print_pagebb.asp

I don't know that I care about being HTML/XHTML compliant, and I'm of the philosophy that the less code in one's webpages the better, but it's worth knowing about, and one more slash at the end doesn't hurt much.

[ http://php.indiana.edu/~erasmuse/w/04.01.21a.htm .     Erasmusen@yahoo.com. ]

To return to Eric Rasmusen's weblog, click http://php.indiana.edu/~erasmuse/w/0.rasmusen.htm.