How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: Why CSS Page Breaks Don’t Work in HTML Tables (and How to Fix It)
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > Web Development > Why CSS Page Breaks Don’t Work in HTML Tables (and How to Fix It)
Web Development

Why CSS Page Breaks Don’t Work in HTML Tables (and How to Fix It)

how7o
By how7o
Last updated: May 23, 2026
5 Min Read
Fix CSS page breaks not working with HTML tables
SHARE

If CSS page-break-after isn’t working on table rows, it’s because the legacy page-break-* properties only apply to block-level elements, and <tr> isn’t one. The modern break-inside: avoid and break-after: page have better table support, but the reliable cross-browser fix is to split long tables into multiple smaller tables separated by block-level page-break dividers.

Contents
  • What doesn’t work
  • Best-effort with modern break-* properties
  • Reliable fix — split the table
  • JavaScript helper to split a table
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-05-17 in Chrome 124, Firefox 125, Safari 17. Originally published 2022-10-19, rewritten and updated 2026-05-17.

What doesn’t work

tr.page-break {
    page-break-after: always;   /* often ignored on table rows */
}

The legacy page-break-* properties were specified only for block-level elements. <tr> has display: table-row, which doesn’t qualify. Browsers either silently ignore the directive or honor it inconsistently.

HTML table page breaks — break-inside avoid, split tables with block divider, repeated thead

Best-effort with modern break-* properties

@media print {
    table {
        break-inside: auto;
    }
    tr {
        break-inside: avoid;     /* don't split a single row across pages */
        break-after:  auto;
    }
    thead {
        display: table-header-group;   /* repeat header on each printed page */
    }
    tfoot {
        display: table-footer-group;   /* repeat footer on each printed page */
    }
}

The break-inside: avoid on tr prevents rows from being split mid-row (a row that doesn’t fit moves to the next page entirely). display: table-header-group on thead makes the header repeat on every printed page — a critical UX touch for long tables.

Reliable fix — split the table

<table>
    <thead><tr><th>Col 1</th><th>Col 2</th></tr></thead>
    <tbody>
        <!-- rows 1–20 -->
    </tbody>
</table>

<div class="page-break"></div>

<table>
    <thead><tr><th>Col 1</th><th>Col 2</th></tr></thead>
    <tbody>
        <!-- rows 21–40 -->
    </tbody>
</table>

<style>
@media print {
    .page-break { break-after: page; }
}
</style>

Render the rows in chunks (whatever fits on one page — usually 20–25 rows). Between each chunk, a block-level <div class="page-break"> forces the next chunk onto a fresh page. break-after: page works reliably on block elements.

JavaScript helper to split a table

function splitTableForPrint(table, rowsPerPage = 20) {
    const tbody = table.querySelector('tbody');
    const rows  = Array.from(tbody.children);
    const head  = table.querySelector('thead').innerHTML;

    let html = '';
    for (let i = 0; i < rows.length; i += rowsPerPage) {
        const chunk = rows.slice(i, i + rowsPerPage).map(r => r.outerHTML).join('');
        html += `<table><thead>${head}</thead><tbody>${chunk}</tbody></table>`;
        if (i + rowsPerPage < rows.length) {
            html += '<div style="break-after: page"></div>';
        }
    }
    table.outerHTML = html;
}

Call this from a “Print” button to transform a single long table into chunked tables before the print dialog opens. The repeated <thead> on each chunk gives every page its own header.

Frequently asked questions

Why don’t page-break-* properties work on <tr>?

The CSS spec only defines page-break behavior on block-level elements. Table rows are display: table-row — neither block nor inline. Browsers historically ignored page breaks inside table internals to keep the table structure intact across pages. Modern break-inside: avoid and break-after: page on tr have better support but still aren’t universal.

What’s the difference between the legacy page-break-* and modern break-* properties?

Same effect, newer name. page-break-before/after/inside are the original CSS 2.1 properties. break-before/after/inside (CSS Fragmentation 3) replaces them and supports more contexts (multi-column, regions). Browser support is essentially identical now. For new code use the unprefixed break-* versions; keep the legacy ones if you support very old browsers.

How can I force a break in a long table reliably?

Wrap the table in chunks. Render N rows in one <table>, then a forced <div style="break-after: page"></div>, then render the next N rows in another <table> with a repeated <thead>. The browser can break between block-level <div>s reliably; trying to break inside a single table is the hard case.

Will browsers automatically repeat the table header on each page?

Yes — <thead> rows are repeated at the top of each printed page when a table spans multiple pages. Same for <tfoot> at the bottom. This works in every modern browser without extra CSS. You only need to structure your markup with the right semantic tags.

Related guides

  • How to Set A4 Paper Size in CSS for Print
  • How to Change the Background Color of a Checkbox with CSS

References

MDN break-before / break-after / break-inside: developer.mozilla.org/en-US/docs/Web/CSS/break-before. MDN page-break-* (legacy): developer.mozilla.org/en-US/docs/Web/CSS/page-break-after. CSS Fragmentation Module Level 3: w3.org/TR/css-break-3.

TAGGED:CSShtmlprint

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article Fix DKIM not signing emails in aaPanel How to Fix DKIM Not Signing Emails in aaPanel
Next Article URL.createObjectURL not a function — Chrome extension service worker fix Fix “URL.createObjectURL is not a function” in Chrome Extension Service Workers
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow
Most Popular
Laravel Eloquent ORM — a model class mapping to a database table with query methods
Laravel Eloquent ORM: The Complete Guide to Querying Your Database
June 16, 2026
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026

You Might Also Like

CSS checkbox background color — accent-color one-liner and hide-and-replace fallback
Web Development

How to Change a Checkbox Background Color with CSS

5 Min Read
Laravel Eloquent orderBy — code snippet sorting posts by id descending with arrow icons
Web Development

How to Use orderBy in Laravel Eloquent (with Examples)

6 Min Read
Store a PHP array in a MySQL database with JSON
Web Development

How to Store a PHP Array in a MySQL Database

5 Min Read
Laravel cURL error 60 SSL certificate problem — CA bundle wiring in php.ini
Web Development

How to Fix cURL Error 60 SSL Certificate Problem in Laravel

9 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?