Angelin Nadar Angelin Nadar - 5 months ago 112
CSS Question

how to avoid extra blank page at end while printing?

I'm using a CSS property,

If I use

page-break-after: always;
=> It prints an extra blank page before

If I use
page-break-before: always;
=> It prints an extra blank page after. How to avoid this?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
page-break-after: always;

<script type="text/javascript">
<div class="print">fd</div>
<div class="print">fdfd</div>


You could maybe add

.print:last-child {
     page-break-after: auto;

so the last print element will not get the extra page break.

Do note that the :last-child selector is not supported in IE8, if you're targetting that wretch of a browser.