<article>
<section>
<p>Section 1</p>
</section>
<section>
<p>Section 2</p>
</section>
<section>
<p>Section 3</p>
</section>
</article>
<div>
<button>Print Webpage</button>
</div>
@page :first {
margin: 45% 5%;
}
body {
background-color: #333;
display: grid;
gap: 3rem;
}
section {
background-color: #c2d1e5;
border-radius: 10px;
display: grid;
margin-block-end: 1.5rem;
padding: 1rem;
place-items: center;
}
section {
page-break-after: always;
break-after: page;
}
document.querySelector("button").addEventListener('click', () => {
window.print();
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.