The break-insideCSS property sets how page, column, or region breaks should behave inside a generated box. If there is no generated box, the property is ignored.
Each possible break point (in other words, each element boundary) is affected by three properties: the break-after value of the previous element, the break-before value of the next element, and the break-inside value of the containing element.
To determine if a break must be done, the following rules are applied:
If any of the three concerned values is a forced break value (always, left, right, page, column, or region), it has precedence. If more than one of them are such a break, the value of the element that appears the latest in the flow is used. Thus, the break-before value has precedence over the break-after value, which in turn has precedence over the break-inside value.
If any of the three concerned values is an avoid break value (avoid, avoid-page, avoid-region, or avoid-column), no such break will be applied at that point.
Once forced breaks have been applied, soft breaks may be added if needed, but not on element boundaries that resolve in a corresponding avoid value.
For compatibility reasons, the legacy page-break-inside property should be treated by browsers as an alias of break-inside. This ensures that sites using page-break-inside continue to work as designed. A subset of values should be aliased as follows:
In the following example we have a container that contains an spanning all columns (achieved using column-span: all) and a series of paragraphs laid out in multiple columns using column-width: 200px. We also have a containing an image and a caption.
By default, it is possible for you to get a break between the image and its caption, which is not what we want. To avoid this, we have set break-inside: avoid on the , which causes them to always stay together.
HTML
html
Main heading
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae
fringilla mauris. Quisque commodo eget nisi sed pretium. Mauris luctus nec
lacus in ultricies. Mauris vitae hendrerit arcu, ac scelerisque lacus.
Aliquam lobortis in lacus sit amet posuere. Fusce iaculis urna id neque
dapibus, eu lacinia lectus dictum.
The Firefox logo — fox wrapped around the world
Praesent condimentum dui dui, sit amet rutrum diam tincidunt eu. Cras
suscipit porta leo sit amet rutrum. Sed vehicula ornare tincidunt. Curabitur
a ipsum ac diam mattis volutpat ac ut elit. Nullam luctus justo non
vestibulum gravida. Morbi metus libero, pharetra non porttitor a, molestie
nec nisi.
In finibus viverra enim vel suscipit. Quisque consequat velit eu orci
malesuada, ut interdum tortor molestie. Proin sed pellentesque augue. Nam
risus justo, faucibus non porta a, congue vel massa. Cras luctus lacus nisl,
sed tincidunt velit pharetra ac. Duis suscipit faucibus dui sed ultricies.