Hi,
You can do it if the header and footer are part of the same table. You can then just use the thead and tfoot elements and good browsers should automatically print the header and footer on every page without doing anything.
For IE you need to add this.
Code:
thead {
display: table-header-group;
}
tfoot {
display: table-footer-group;
}
Here's an example that works in IE7 and Firefox (not sure about others).
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
* {
margin:0;
padding:0
}
table {
width:100%
}
td, th {
border:1px solid #000;
text-align:center;
padding:5px;
}
tfoot td {
font-weight:bold;
}
thead {
display: table-header-group;
}
tfoot {
display: table-footer-group;
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<caption>
Table example
</caption>
<thead>
<tr>
<th scope="col">header 1</th>
<th scope="col">header 2</th>
<th scope="col">Header 3</th>
</tr>
</thead>
<tfoot>
<tr>
<td>footer 1</td>
<td>footer 2</td>
<td>footer 3</td>
</tr>
</tfoot>
<tbody>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
<tr>
<th scope="row">Row </th>
<td>content</td>
<td>content</td>
</tr>
</tbody>
</table>
</body>
</html>
Bookmarks