ConfusedUser
ConfusedUser

Reputation: 391

Print html to multiple page

Assuming we have multiple html paragraph

<p>Paragraph 1</p>
<p>Paragraph 2</p>

Is there a way to print both to different page to the printer ?

Paragraph 1 would be printed on the first page and Paragraph 2 would be printed on the second page.

Thank You

Upvotes: 16

Views: 27624

Answers (1)

antyrat
antyrat

Reputation: 27765

You can do this using CSS page-break-after property:

@media print {
    p { page-break-after: always; }
}

It will print each p element on new page.

window.print()
@media print {
    @page { margin: 0; }
    p { page-break-after: always; }
}
<p>Paragraph 1</p>
<p>Paragraph 2</p>

Upvotes: 35

Related Questions