0

I have a HTML question:

If I have a table with multiple thead, on printing this page, the repetition on top of next page is first thead and not the last one.

Example:

<table>
      <thead>
        <tr>
          <th>TH 1</th>
          <th>TH 2</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>TD 1</td>
          <td>TD 2</td>
        </tr>
        <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
          <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
          <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
      </tbody>
      <thead>
        <tr>
          <th>TH 3</th>
          <th>TH 4</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>TD 1</td>
          <td>TD 2</td>
        </tr>
        <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
          <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
          <tr>
            <td>TD 1</td>
            <td>TD 2</td>
          </tr>
      </tbody>

The second-page header shows TH1 and TH2 instead of TH3 and TH4 during print preview.

Is there a way to print TH3 and TH4?

  • Multiple thead elements are invalid html, see https://stackoverflow.com/questions/16155396/multiple-thead-tbody-in-table-valid - so it seems like the browser treats the first one as valid and omits everything after. Why would you want to display other information for the second page? – Hans Spieß Apr 30 '21 at 21:48
  • My idea is to have an easy way to have header and footer for page printing, so as head and tfoot do this repetition, the idea is if header changes, it reflects for any page break, showing the thead for the last head (indicating the table belongs to the head) – Marcos Felipe Donadeli Gonalez Apr 30 '21 at 23:09
  • So you want numbered pages? That is a different thing, `thead` is not meant to solve this. Try out the solution outlined in https://stackoverflow.com/a/20317775/3787407 – Hans Spieß Apr 30 '21 at 23:18

0 Answers0