Using CSS to keep paragraphs/blocks together when printing

Is there a way to keep a block of text together, either in a DIV tag or as P tag, when you print a page? Example. A quotation page with many items, and at the end there is a disclaimer and signature area that must be together, either on the first page or next page.

Is this possible at all??  I have searched but cannot see anything for this.
mandymooAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David S.Commented:
Try using the page-break-before property: http://reference.sitepoint.com/css/page-break-before
0
mandymooAuthor Commented:
Unfortunately this doesn't fix the problem.
Applying this to the #invfooter DIV style, still allows its contents to be split over 2 pages, as I'm wanting either all the info on the same page (if short quote) or the info to be on the next page in full.

Code sample:
#invfooter {
      clear: both;
      width: 650px;
      margin-top: 0px;
      margin-right: auto;
      margin-left: auto;
      font-size: 11px;
      line-height: 14px;
      text-align: right;
      page-break-before: auto;
}

I have also tried "orphans"... do I have to use them both together?? Again I have tried this above with "orphans: 12".

Any other suggestions?
0
quincydudeCommented:
try page-break-after

see the examples in on how to use it, and set it to always
http://www.jonasjohn.de/snippets/html4strict/css-pagebreak.htm
0
David S.Commented:
It seems I should have explained more.

The property you want is page-break-inside, however, only recent versions of Opera support it, so it won't do you much good. Likewise, only recent versions of Opera are the only browsers to support the orphans and widows properties.

Thus you're stuck with page-break-before and page-break-after. The default value for each of those properties is "auto", so declaring it doesn't do any good. Because browsers only partially support those properties you're down to two choices: page-break-before:always and page-break-after:always
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mandymooAuthor Commented:
Right, Ok. Thanks Kravimir.

I was a little discouraged, but I have resolved the issue with a little help from PHP!

They way I got around it was to have a form on my print page, where I can indicate if I want to break the page or not. After indicating I want to break the page, it passes a value to the URL string of "break=always" to the same page. Then, in my stylesheet, I added the variable to it. The CSS is called in when the page loads and everything works beautifully.

Code sample:
#invfooter {
     ....
      page-break-before: $_GET['break'];
}

So a combination of CSS & PHP allows me to break the page at a certain place if the page is too long for 1 page.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.