-1

I have a very large HTML table (which can be dynamic i.e. no of rows and columns are not fixed) that I need to print. Clearly, the rows that dont fit in the same page will be printed on the next page. But I also want all the columns that dont fit in the same page to be printed in another page. I researched for quite a time but I couldnt find any way to perform that without applying an empirical logic. Right now, I am opting to print a pre-defined number of columns in a page.

Can the CSS properties page-break-after or page-break-before to achieve something like that? If so, how?

aayush shrestha
  • 1,858
  • 2
  • 17
  • 33

1 Answers1

1

You can't control that with CSS.

The specs define where page-breaks may occur:

  1. In the vertical margin between block-level boxes. [...] // e.g. between table rows
  2. Between line boxes inside a block container box.
  3. Between the content edge of a block container box and the outer edges of its child content[...]

http://www.w3.org/TR/CSS2/page.html#allowed-page-breaks

Table columns are not part of that. So an overly-wide table-row must be on one page, but will exceed its width. The specs also mention how this situation may be handled:

When formatting content in the page model, some content may end up outside the current page box. [...] The exact formatting of such elements lies outside the scope of this specification. [...] User agents may handle boxes positioned outside the page box in several ways, including discarding them or creating page boxes for them at the end of the document.

http://www.w3.org/TR/CSS2/page.html#outside-page-box

In other words, browsers might do whatever they want.

This is still true in the upcoming CSS3 specs

Community
  • 1
  • 1
user123444555621
  • 148,182
  • 27
  • 114
  • 126