Forum How do I...?

Repeating Table Headers with columns

joelmeador
A DocRaptor customer is trying to make content from <th>s span multiple pages and columns, and I can't figure out a way to do it.

I am attaching a basic version of what I want to work and am curious what CSS (if any) I could use to get this to work. What I am looking for is to see "A Header!" appear at the top left corner of the columns on the first and second pages. Any help is much appreciated.
  1. multi-page-column-header-test.html0.9 kB
mrwarper
Maybe stuff has broken over time in regular browsers, is not working in Prince (can't test right now), or I'm misunderstanding you, but on my very old work Mozilla, plain <th>s properly placed in their corresponding <thead> repeat on all the pages their ancestor table spans -- no need for special CSS of any kind.

I added some rows to a simplified version of your example to ensure it goes beyond page 1 and just hit print -- as I understood it, it works as is:

th in thead.png
  1. multi-page-column-header-test.html1.3 kB
    No special CSS, just colours
  2. th in thead.png10.9 kB
    Ancient Mozilla print output (composite)
mikeday
Column breaking is equivalent to page breaking, so you can't make a single <th> span across columns, only across table columns.
mrwarper
And for that CSS is not the answer either -- HTML attribute "colspan" suffices. F.e:

<table>
<thead>
<tr><th colspan="2">Pairs</th></tr>
<tr><th>Column A</th><th>Column B</th></tr>
</thead>
<tbody>
<tr><td>Something</td><td>Something else</td></tr>
</tbody>
</table>
joelmeador
@mrwarper: First, thanks for the feedback! But, I don't think you understood the problem I was trying to solve given your answers. It is basically a multi-column layout wherein the content is all in table cells and spans multiple pages, and the ask was: can I make table head elements also span across pages without repeating at the top of each column, but instead only on one column per page.

@mikeday: That makes sense, and this certainly seems like a corner case. I already recommended to my customer they try manually columnizing the table structure using sub-tables or display: table stuff so I guess I will double down on that. Thanks for the answer. :)
mrwarper
joelmeador: Excuse me for going astray -- your question is much clearer now, thank you :)

Unfortunately, because of what mikeday said, I don't think it's possible for content in <thead>s to repeat on every page but not on every content column -- to auto-repeating elements it should not make a difference where the break comes from, unless the CSS model is expanded to reflect that nuance. However, I'm not current on the latest developments in that direction, so don't take this as a flat-out 'no.'

Edited by mrwarper