 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set the page-break behavior inside an element with JavaScript?
Use the pageBreakInside property in JavaScript to set the page-break behavior inside an element. Use the auto property to insert page break inside an element. Use auto or avoid property value to automatically insert page break inside an element, if needed, or avoid a page break, respectively.
Note − The changes would be visible while printing or viewing the print preview.
Example
You can try to run the following code to return the page-break behavior inside an element with JavaScript −
<!DOCTYPE html> <html>    <body>       <h1>Heading 1</h1>       <p>This is demo text.</p>       <p>This is demo text.</p>       <p id = "myFooter">This if footer text.</p>       <button type = "button" onclick="display()"> Set page-break </button>             <script>          function display() {             document.getElementById("myFooter").style.pageBreakInside = "auto";          }       </script>    </body> </html>Advertisements
 