Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    12
    Thanked 0 Times in 0 Posts

    code to achieve page breaks when printing ?

    Hi,

    The visitors of my site to 99% live in countries where A4 is the standard paper size. Can I code my webpages so that they print nicely on A4, so that paragraphs are not broken up between printed pages?

    A workaround would be to offer a printable PDF, but I would like to avoid that if possible,

    Thanks!

    /g

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by guermantes View Post
    Hi,

    The visitors of my site to 99% live in countries where A4 is the standard paper size. Can I code my webpages so that they print nicely on A4, so that paragraphs are not broken up between printed pages?

    A workaround would be to offer a printable PDF, but I would like to avoid that if possible,

    Thanks!

    /g
    If you want to set page breaks (I don't think you can specify paper size to use with breaks, but you can just set general page breaks) then check this out:
    http://www.w3schools.com/css/css_ref_print.asp
    and this one in particular:
    http://www.w3schools.com/css/pr_print_pagebb.asp

    Here is one example:
    Code:
    p
    { 
    page-break-before: always;
    }
    If you leave that as "always" then it will page break in the printing even if not necessary, but if you leave it as "auto" then it should allow a page break right before the element when needed (in other words, I believe it should work with any page size if it is ever needed to start a paragraph on a new page if it would wrap to a second one).

    Let me know if this is what you're looking for.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • Users who have thanked Rowsdower! for this post:

    guermantes (05-15-2009)

  • #3
    New Coder
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thanks a lot!

    That seems to be exactly what I am after.

    Cheers!

    /g


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •