tags:

views:

3594

answers:

3

Is it possible in CSS using a property inside an @page to say that table headers (th) should be repeated on every page if the table spreads over multiple pages?

+5  A: 

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

tvanfosson
I haven't thought about that, but it doesn't seem to work in practice.
Alessandro Vernet
I have successfully used that in Firefox.
jishi
As usual, it requires a non-broken browser -- see jishi's comment.
Peter Rowell
+4  A: 

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;}

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

(source)

nickf
Neither does Flying Saucer, which I am using to generate a PDF. I will also ask this question on the Flying Saucer mailing list to see if there is another way to do this.
Alessandro Vernet
A: 

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.)

Eero