Syntax
.card { break-inside: avoid; }
h2 { break-after: avoid; }Examples
Controlling Page and Column Breaks: working example
Run this CSS against the example’s own HTML. The explanation describes the expected result.
/* Neutral page for this self-contained document. */
body { color: #182338; background: #fff; }
.columns { columns: 2; max-width: 40rem; }
section { break-inside: avoid; border: 1px solid; margin-bottom: 1rem; padding: 1rem; }
h2 { break-after: avoid; }
@media print { .columns { columns: auto; } section { break-inside: avoid; } }- Expected result: Each bordered schedule section is kept together when it fits; print preview uses one column with the same avoidance rule.
- The screen layout demonstrates column fragmentation.
- Avoid is a constraint the browser may relax when a box cannot fit in a fragment.
HTML used by this example
<div class="columns"><section><h2>Morning</h2><p>Arrival and introduction.</p></section><section><h2>Afternoon</h2><p>Practical workshop and review.</p></section><section><h2>Evening</h2><p>Questions and closing notes.</p></section></div>
Best practices
- Inspect print preview using realistic content lengths.
- Do not assume avoid guarantees that arbitrary content always fits one page.
Runtime & versions
Web browsers. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
CSS specifications (modules)