Firefox truncates long tables when printing

I stumbled across a weird bug in Firefox today — a bug that apparently has been around for quite some time, as it was originally reported on 2005-05-20.

If you have a table which is longer than the page, in certain situations, when printing the page, a page break is forced before the table, and only the first visible page of the table prints, with the rest of the content disappearing altogether.

The original bug report describes it rather well:

… The first [page] contains material preceding the table, the second [page] contains most but not all of the table, and the third [page] is empty.

The bug was confirmed on 2005-06-19, but no fixes followed. On 2006-07-31 a user alluded to a workaround:

From further tests, you can see that the bug happens when BOTH THE FOLLOWING
CONDITIONS are respected:

A) The page contains an <h1> title
B) The table in the page contains a <caption>caption

The web page in my project which was exhibiting this bug had an h1 at the top of the page and a caption at the top of the offending table. Removing the caption from the markup fixed the problem, as did applying the display:none style to the caption.

It’s a frustrating bug, but once you know the workaround, it’s easy to deal with.