HTML
CSS
JavaScript
<div class='content'> <h1>Chapter 1</h1> <p>This is the first chapter of the document.</p> </div> <div class='new-chapter'> <h1>Chapter 2</h1> <p>This is the second chapter of the document.</p> </div>
.content { margin: 20px; } .new-chapter { page-break-before: always; margin: 20px; background-color: #f0f0f0; padding: 10px; border: 1px solid #ccc; }
// No JavaScript required for this demo
Chapter 1
This is the first chapter of the document.
Chapter 2
This is the second chapter of the document.