Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat table headers in print mode

Tags:

css

css-tables

People also ask

How can you automatically repeat the table headings on every page in Word?

Select the header row, right click to select Table Properties from context menu. 2. In the Table Properties dialog, under Row tab, check Repeat as header row at the top of each page option.

Why won't the table headers repeat in Word?

Make sure that your long table is actually a single table. If it is not, then the header row won't repeat because the table doesn't really extend beyond a single page. The easiest way to determine if you are working with a single table vs. multiple tables is to click somewhere within the table.


This is what the THEAD element is for. Official docs here.


Some browsers repeat the thead element on each page, as they are supposed to. Others need some help: Add this to your CSS:

thead {display: table-header-group;}
tfoot {display: table-footer-group;}

Opera 7.5 and IE 5 won't repeat headers no matter what you try.

(source)


Flying Saucer xhtmlrenderer repeats the THEAD on every page of PDF output, if you add the following to your CSS:

        table {
            -fs-table-paginate: paginate;
        }

(It works at least since the R8 release.)


UPDATE: It looks like this may have been fixed in 2016! https://bugs.chromium.org/p/chromium/issues/detail?id=24826#c45

Original Answer (2012): Before you implement this solution it's important to know that Webkit currently doesn't do this.

Here is the relevant issue on the Chrome issue tracker: http://code.google.com/p/chromium/issues/detail?id=24826

And on the Webkit issue tracker: https://bugs.webkit.org/show_bug.cgi?id=17205

Star it on the Chrome issue tracker if you want to show that it is important to you (I did).