Fragmentation and breaks
Definition and purpose
A fragmentainer is a region such as a page or column that holds a fragment of a continuous flow. Fragmentation divides eligible boxes at allowed break points. break-before and break-after can request forced or avoided breaks; break-inside discourages breaks within an element.
Natural column break
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { width: 300px; height: 100px; column-count: 2; column-gap: 20px; column-fill: auto; } section { height: 40px; break-inside: avoid; } </style> </head> <body> <article id="a"> <section id="x">First section</section> <section id="y">Second section</section> <section id="z">Third section</section> </article> </body></html>Two sections fit in the first column, and the third moves to the next.
Syntax and mental model
In a multicol context, break-before: column forces the next section to a new column. Avoidance is a preference, not an absolute guarantee when content cannot fit. orphans sets the minimum lines to leave at the end of the preceding fragment; widows sets the minimum lines to put at the beginning of the next fragment. The algorithm can relax avoidance constraints to make progress. The examples use equal-height sections for deterministic column placement, and inspect widow/orphan declarations rather than asserting a universal pagination result.
Forced column break
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { width: 300px; height: 100px; column-count: 2; column-gap: 20px; column-fill: auto; } section { height: 40px; break-inside: avoid; } #y { break-before: column; } </style> </head> <body> <article id="a"> <section id="x">First section</section> <section id="y">Second section</section> <section id="z">Third section</section> </article> </body></html>The second section starts the next column even though it could fit in the first.
Common mistakes
Do not assume break-inside: avoid keeps a box larger than a whole page intact. Inspect actual fragments and test print or column dimensions, rather than relying only on the declaration.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Multi-column layout. Next lesson: Paged media and print.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fragmentation and breaks — knowledge check
Five questions on fragmentation and breaks.
What is a fragmentainer?
Which declaration forces a column break before an element?
What does widows constrain?
What does orphans constrain?
Can break-inside avoidance be relaxed?