Hi all,
Is it possible to satisfy the following conditions:
* Allow a table to break across pages
* Always keep a table caption (below the table) with the table (so, if the caption would be on its own on a page, include the last row of the table with the caption on the same page)
I initially applied page-break-inside: avoid to a div tag surrounding the table and caption. But if the table was longer than a page, it started on a new page.
I then tried page-break-before: avoid on the caption itself. But if the table went to the end of a page, the caption was placed on the next page.
Any help appreciated,
Paul
Keep caption with table but allow table to break
Re: Keep caption with table but allow table to break
I am surprised page-break-before: avoid; on the caption element does not work. But maybe try to use a complex selector:
tr:last-of-type {
page-break-after: avoid;
}
This will apply the page break formatting to the last table row, which you can additionally specify to be tables of a certain class [ones expected to have captions].
You might also try to generate a help output with the same settings as your print output and use the inspect feature in the browser to see if there is anything else getting in there between the table and the caption that is messing things up, and to make sure the CSS style is actually being applied to the caption.
tr:last-of-type {
page-break-after: avoid;
}
This will apply the page break formatting to the last table row, which you can additionally specify to be tables of a certain class [ones expected to have captions].
You might also try to generate a help output with the same settings as your print output and use the inspect feature in the browser to see if there is anything else getting in there between the table and the caption that is messing things up, and to make sure the CSS style is actually being applied to the caption.
Re: Keep caption with table but allow table to break
I've tried several variations on this with no luck. I even create a class style named tr.last-of-type with the following definition and applied it to the last row (using styling just to make sure the class style is taking effect):devjoe wrote:I am surprised page-break-before: avoid; on the caption element does not work. But maybe try to use a complex selector:
tr:last-of-type {
page-break-after: avoid;
}
This will apply the page break formatting to the last table row, which you can additionally specify to be tables of a certain class [ones expected to have captions].
You might also try to generate a help output with the same settings as your print output and use the inspect feature in the browser to see if there is anything else getting in there between the table and the caption that is messing things up, and to make sure the CSS style is actually being applied to the caption.
Code: Select all
tr.last-of-type
{
font-weight: bold;
background-color: #bde9ba;
page-break-after: avoid;
}