CSS Reference ยท Multi-column and Fragmentation
The break-inside property
Reference for the CSS break-inside property: stop cards, figures and table rows from splitting across columns or printed pages, with live examples.
The break-inside property controls whether a box may be split across columns or pages. Its main job is break-inside: avoid, which asks the browser to keep a box in one piece: a card in a multi-column layout, a figure with its caption, a table row, a code sample in a printed page.
Unlike break-before and break-after, break-inside has no "force" values, because forcing a break inside an unknown box makes no sense.
.card { break-inside: avoid; }
Try it
In the left example a card may be cut at the bottom of the first column, with its last lines at the top of the next. On the right, a card that does not fit moves completely into the next column.
Syntax
break-inside: auto | avoid | avoid-page | avoid-column | avoid-region;
- Initial value:
auto - Applies to: block-level boxes, grid items, flex items, table rows and row groups (not inline boxes)
- Inherited: no
- Animatable: no (discrete)
- Computed value: as specified
Values
| Value | Description |
|---|---|
auto |
The box may be split wherever it is necessary. The default. |
avoid |
Avoid breaking inside the box, in any kind of fragmentation. |
avoid-page |
Avoid a page break inside the box. |
avoid-column |
Avoid a column break inside the box. |
avoid-region |
Avoid a region break inside the box. |
Usage notes
- Great for masonry-like columns. Multi-column card lists look broken when a card is cut in two. Add
break-inside: avoidto each card. - Boxes taller than a column will still split. If the box is larger than one column or page, the browser has to break it.
- Large avoided boxes cost space. Keeping a tall box whole may leave a large empty gap at the bottom of the previous column. Keep the avoided boxes reasonably small.
- Inline boxes are not covered. To keep a heading and the first lines of its paragraph together, use
break-after: avoidon the heading. - Legacy name.
page-break-insideis the older property and works forautoandavoid. - Combine with
display: inline-blockhacks only if needed. Some old stylesheets used them to avoid splits;break-insideis the modern, direct way.
Browser support
break-inside: avoid works in current browsers for printed pages and for multi-column layout; check a compatibility table for the column-specific and region values.
Related
break-beforeandbreak-afterorphansandwidowsโ lines of text at a breakcolumnsโ multi-column layout- Lesson: Multi-column Layout, Print Styles