title: Non Repeating Table Footer That Avoids Breaking Over Printed Pages CSS
body: <p>So I have a weird situation were I have a table footer that I only need to repeat once so I decided to just add the "footer" <code>trs</code> to the end of the <code>tbody</code> so it would only appear once at the end of the table and look like a footer without the repeating on each printed page.</p>
  
  <pre><code>&lt;table&gt;
      &lt;tbody&gt;
          @foreach(var item in Model.Items)
          {
              &lt;tr&gt;&lt;td&gt;@item.Name&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;@item.Total&lt;/td&gt;&lt;/tr&gt;
          }
          &lt;tr&gt;
              &lt;td&gt;Total&lt;/td&gt;
              &lt;td&gt;@Model.Items.Sum(x  =&gt; x.Total)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Discount&lt;/td&gt;
              &lt;td&gt;@(Model.Items.Sum(x =&gt; x.Total) / 50)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>This was fine until <code>Model.Items</code> had enough rows that it pushed the second row of the footer onto the next page when I need to keep the two footer rows together.</p>
  
  <p>I've also tried using the actual <code>tfoot</code> tag like so with a <code>page-break-inside:avoid</code> style.</p>
  
  <pre><code>&lt;table&gt;
      &lt;tbody&gt;
          @foreach (var item in Model.Items)
          {
              &lt;tr&gt;&lt;td&gt;@item.Name&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;@item.Total&lt;/td&gt;&lt;/tr&gt;
          }
      &lt;/tbody&gt;
      &lt;tfoot style="page-break-inside:avoid;"&gt;
          &lt;tr&gt;
              &lt;td&gt;Total&lt;/td&gt;
              &lt;td&gt;@Model.Items.Sum(x =&gt; x.Total)&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Discount&lt;/td&gt;
              &lt;td&gt;@(Model.Items.Sum(x =&gt; x.Total) / 50)&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tfoot&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>This kept the footer together but its now repeating on each page instead of once. Someone on another Stack Overflow question suggested using the following style on the <code>tfoot</code> to stop it repeating which worked, but now it ignores the <code>page-break-inside:avoid</code> style.</p>
  
  <pre><code>&lt;tfoot style="display: table-row-group"&gt;&lt;/tfoot&gt;
  </code></pre>
  
  <p>Does anyone know how to get a footer to appear once and avoid breaking over multiple printed pages?</p>