Forum Moderators: open

Message Too Old, No Replies

Printing Long Tables

Print the table header on every page

         

ceri

4:02 pm on Jan 22, 2004 (gmt 0)



According to the HTML 4 specification, it is possible to use the <thead> element to declare information would should be printed at the top of every page that the table is printed on.

This would be a great feature, but I cannot seem to get it to work in IE6. Does anyone know if it is supported? The only thing I can think of is that I haven't set the doctype correctly. The code I'm using is below.

Can anyone help? Thanks,
Ceri

-------------------------------------

<table border = "1">
<thead>
<tr>
<td>This text is in the THEAD</td>
</tr>
</thead>
<tfoot>
<tr>
<td>This text is in the TFOOT</td>
</tr>
</tfoot>
<tbody>

<tr>
<td>This text is in the TBODY</td>
</tr>
<tr>
<td>This text is in the TBODY</td>
</tr>
.
.
.
</tbody>
</table>
------------------------------------

[edited by: tedster at 5:40 pm (utc) on Jan. 22, 2004]

txbakers

6:09 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure HTML knows when page breaks occur.

I do this by counting the number of rows returned and just plain guessing where to drop the headers.

Remember, people will set their page setup margins differently and will have different resolution screens. Font size will also affect the outcome.

If you are good with CSS you could make your body part of the table scrollable so the headers will always stay visible. But that won't help with printing.

4serendipity

8:46 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



One thing that you can do now is set page breaks in an CSS print style sheet using page-break-after and page-break-before. These two properties are supported in the latest versions of IE, NN/Moz, and Opera.
[w3.org...]

Again, you'll have to guess where the page braks will occur, picking a paper size and page orientation to optimize for (i.e., letter size paper with portrait orientation). Setting your font-size to absolute point size in your print style sheet might be a good idea as well.

Of course, user-set properties such as page margins can always cause variances that will affect the amount of text printed to each page.

In CSS3 there is a mechanism defined for the placement of running page headers and footers. An example given in the documentation is:

<style>
@page {
@top-left{
font-family: Helvetica, Arial, sans-serif;
font-size: 18pt150%;
font-weight: bolder;
text-align: left;
content: "XHTML-Print: A Proposal --- August 25, 2000";
}
}
</style>

[w3.org...]

Unfortunately, this doesn't help you much with your current problem.

In the end, if I had a page with tabular data that I thought my users would frequently print out, I'd create a PDF version of the page to ensure a consistent priint layout that had column headers at the top of each page.