CSS | page-break-inside Property

The page-break-inside property in CSS is used to specify how the page breaks inside the element to which it is applied while printing. It inserts a page break or sometimes it used to avoid page break inside an element while printing.

Syntax:

page-break-inside: auto|avoid|initial|inherit

Property Values:

  • auto: It is the default value. This value represents the page break automatically.

    Syntax:

    page-break-inside: auto;
  • avoid: It avoids a page break inside the element.
    Syntax:

    page-break-inside: avoid;
  • initial: It sets the page-break-inside property to its default value.
    Syntax:

    page-break-inside: initial;
  • inherits: The page-break-inside property is inherited from its parent.
    Syntax:

    page-break-inside: inherits;

Note: This property is mostly used to print a document.

Print Media Query:

@media print {
    img {
        display: block;
        page-break-inside: avoid;
    }
}

Example 1: This example use page-break-inside property value to avoid.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>
        CSS page-break-inside property
    </title>
      
    <style type="text/css">
        @media print {
            ul {
              page-break-inside: avoid;
            }
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
      
    <h2>CSS page-break-inside property</h2>
      
    <br><br><br>
      
    <img src
    alt = "" />
      
    <br><br><br><br>
  
    <p>
        Prepare for the Recruitment drive of product based
        companies like Microsoft, Amazon, Adobe etc with a
        free online placement preparation course. The course
        focuses on various MCQ's & Coding question likely to
        be asked in the interviews & make your upcoming 
        placement season efficient and successful. 
    </p>
  
<br><br><br>
  
    <img src
    alt = "" />
      
    <ul>
        <li>Data Structure</li>
        <li>Algorithms</li>
        <li>C Programming</li>
        <li>C++ Programming</li>
        <li>Java Programming</li>
        <li>Python Programming</li>
        <li>PHP Programming</li>
        <li>Operating System</li>
        <li>Computer Networks</li>
        <li>DBMS</li>
        <li>SQL</li>
        <li>TOC</li>
    </ul>
</body>
  
</html>                    

chevron_right


Output:
Print Preview:

Example 2: This example use page-break-inside property value to none.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>
        CSS page-break-inside property
    </title>
      
    <style type="text/css">
        @media print {
            ul {
              page-break-inside: none;
            }
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
      
    <h2>CSS page-break-inside property</h2>
      
    <br><br><br>
      
    <img src
    alt = "" />
      
    <br><br><br><br>
  
    <p>
        Prepare for the Recruitment drive of product based
        companies like Microsoft, Amazon, Adobe etc with a
        free online placement preparation course. The course
        focuses on various MCQ's & Coding question likely to
        be asked in the interviews & make your upcoming 
        placement season efficient and successful. 
    </p>
  
<br><br><br>
  
    <img src
    alt = "" />
      
    <ul>
        <li>Data Structure</li>
        <li>Algorithms</li>
        <li>C Programming</li>
        <li>C++ Programming</li>
        <li>Java Programming</li>
        <li>Python Programming</li>
        <li>PHP Programming</li>
        <li>Operating System</li>
        <li>Computer Networks</li>
        <li>DBMS</li>
        <li>SQL</li>
        <li>TOC</li>
    </ul>
</body>
  
</html>                    

chevron_right


Output:
Print Preview:

Supported Browsers: The browser supported by page-break-inside property are listed below:

  • Google Chrome 1.0
  • Internet Explorer 8.0
  • Firefox 19.0
  • Safari 1.3
  • Opera 7.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.