CSS break-after Property

CSS break-after Property

 

CSS break-after Property


The break-after is a CSS property that defines how any break (page, column) should behave after the generated box. It has four values: auto, avoid, always, all.

Inside a multicol container, which was inside a page container would force a column and page break.

This property is deprecated.

Each element boundary is touched by the three properties below:

  • Break-after, which is the value of the previous element.
  • Break-before, which is the value of the next element.
  • Break inside, which is the value of the containing element.

Apply the rules below, to decide if a break must be done:

  1. If one of the three values above is a forced break value (left, right, always, page, region, or column), it has a priority. If more than one of these values is a forced break, the value of the element turned up the latest is used. For example, the break-before value has a priority over the break-after value, and the break-after value has a priority over break-inside value.
  2. If one of these three values is an avoid break value (avoid, avoid-page, avoid-column, or avoid-region) such a break will not be applied.
Initial Valueauto
Applies toBlock-level elements.
InheritedNo.
Animatablediscrete
VersionCSS3
DOM Syntaxobject.style.breakAfter = "always";

Syntax

break-after: auto | avoid | always | all | initial | inherit;

Example of the break-after property:

<!DOCTYPE html>
<html>
  <head>
    <title>The title of the document</title>
    <style>
      .multicol {
        background-color: #eee;
        padding: 10px;
        /* Safari and Chrome */
        -webkit-column-count: 3;
        -webkit-column-rule: 2px dotted #ccc;
        /* Firefox */
        -moz-column-count: 3;
        -moz-column-rule: 2px dotted #ccc;
        /* CSS3 */
        column-count: 3;
        column-rule: 2px dotted #ccc;
      }
      .multicol hr {
        break-after: column;
      }
    </style>
  </head>
  <body>
    <h2>Break-after property example</h2>
    <div class="multicol">
      <h2>Lorem ipsum</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis, arcu ut pulvinar sollicitudin, enim purus mollis tellus, et porta elit sem in nulla. Integer a magna eget justo convallis porta. Vestibulum lacinia eget leo sed elementum. Quisque dapibus ullamcorper quam, at pretium quam eleifend a. Donec sit amet blandit risus. Nunc tempus tellus vitae nibh pellentesque imperdiet. Ut pulvinar rhoncus velit, ut euismod odio ornare vel.</p>
      <hr>
      <h2>Lorem ipsum</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis, arcu ut pulvinar sollicitudin, enim purus mollis tellus, et porta elit sem in nulla. Integer a magna eget justo convallis porta. Vestibulum lacinia eget leo sed elementum. Quisque dapibus ullamcorper quam, at pretium quam eleifend a. Donec sit amet blandit risus. Nunc tempus tellus vitae nibh pellentesque imperdiet. Ut pulvinar rhoncus velit, ut euismod odio ornare vel.</p>
    </div>
  </body>
</html>

Values

ValueDescription
autoAllows inserting any area (page, column) after the principal box.
avoidAvoids inserting any break after the principal box.
alwaysForces to insert any break.
allForces to insert any break.
initialSets this property to its default value.
inheritInherits this property from its parent element.
Reactions

Post a Comment

0 Comments

close