View Full Version : Looking to freeze table headers

10-09-2003, 07:36 PM
Is there someway to freeze the header row of a table so if there are many rows you can still see the headers?

Thanks in advance,

10-09-2003, 08:06 PM
Frames (http://www.w3schools.com/html/html_frames.asp).

10-09-2003, 09:17 PM
Frames won't allow (without pixel-based positioning of cells, which should be avoided) the headers outside a scrolling area to line up with the columns inside the scrolling area.

Try something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<title>Scrolling Table Body</title>
<style type="text/css">
table.scroll {
height: 3em;
overflow: scroll;
table.scroll tbody {
height: 2em;
overflow: auto;
table.scroll tbody tr, table.scroll tbody td {
height: auto;
<table class="scroll">
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Footer 1</th>
<th>Footer 2</th>
<th>Footer 3</th>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
<td>Row 1, Cell 3</td>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
<td>Row 2, Cell 3</td>
<td>Row 3, Cell 1</td>
<td>Row 3, Cell 2</td>
<td>Row 3, Cell 3</td>
<td>Row 4, Cell 1</td>
<td>Row 4, Cell 2</td>
<td>Row 4, Cell 3</td>

It won't be very backward-compatible, but it should treat you just fine in modern browsers. A little testing proves my theory correct: it works in Firebird, and fails in IE 6.

Well, I'm sure there's some way.

10-10-2003, 11:55 PM
Thanks, that did the trick!