www.webdeveloper.com
Results 1 to 4 of 4

Thread: How do you add a page break to HTML?

  1. #1
    Join Date
    Mar 2003
    Location
    NJ
    Posts
    126

    Question How do you add a page break to HTML?

    I have generated a long report which displays via HTML. The users want to print the report (using the browser print). They also want page breaks at certain points in the printed document.

    I have only the faintest idea how to force a page break in HTML. It has something to do with the CSS2 tag "page-break-before" (or "after"). But I can't get it to work. Here's what I've tried:

    Code:
    <style type='text/css'>
       .new {page-break-before}
    </style>
    
    <span class="new"> Title1 </span>
           print out lots of info...
    <span class="new"> Title2 </span>
    Etc.
    Please tell me if there's a way, and how, to insert code into HTML which will force a page break when the page is printed.

    Thanks in advance.
    -Jeff

  2. #2
    Join Date
    Nov 2004
    Location
    Dallas
    Posts
    41
    Try taking it out of the css rule and put it in where you want the page break.

    code:
    <style type='text/css'>

    </style>

    <span class="new"> Title1 </span>
    print out lots of info...
    <span style="page-break-before: always;"> Title2 </span>
    Etc.

    page-break-before: always - forces a page break.
    page-break-before: auto - allow browser to place the break.

  3. #3
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Most browsers only accept the code inline for controlling page breaks, plus you didn't give the attribute a value.

    Code:
    <span style="page-break-before:always;"> Title1 </span>
           print out lots of info...
    <span style="page-break-before:always;"> Title2 </span>
    Stephen

  4. #4
    Join Date
    Mar 2003
    Location
    NJ
    Posts
    126
    Silly me. Of course I need a value. Duh!
    Thanks, all!
    -Jeff

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Posting Permissions

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



Recent Articles