Stategies for printing multiple pages of HTML tables and handling page breaks

I saw this similar question.

(I highlighted the important bits to speed up the reading of the question)

To add to this, I would like to format the HTML table (with a large number of rows) so that when printing it repeats the table headers after each page break . In other words, so that the table headers appear at the top of each printed page.

Some of the things I tried were when generating HTML, counting the number of lines, and then the empty lines, where I expected a page break. . At this point, I would put the table headers again.

However, depending on which printer is used, the page breaks in different places . Since each printer has slightly different margin settings, font sizes, etc.

This, of course, discards the whole idea of ​​predicting where a page break will occur.

What strategies do other people use to print HTML tables and forms while maintaining the correct formatting?

any ideas?

+6
html css printing
source share
1 answer

In your own link published by David Thomas answers:

On a tangent, it might be worth adding into a table with the following css thead {display: table-header-group; } to print the table header on all subsequent pages (useful for loooooong data tables). - David Thomas

What is wrong with this decision? Isn't that consistent with the bill?

About table-header-group :

table-header-group (In HTML: THEAD)

Like "table-row-group", but for visual formatting, a group of rows is always displayed before all other rows and groups of rows and after any top captions. Printed user agents can repeat header lines on each page stretched over a table. If the table contains several elements with "display: table-header-group", only the first is displayed as a header; others are treated as if they were displaying: table-row-group.

+3
source share

All Articles