how to avoid extra blank page at end while printing?

Angelin Nadar picture Angelin Nadar · Oct 21, 2011 · Viewed 141.6k times · Source

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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
.print{
    page-break-after: always;

}
</style>
<script type="text/javascript">
window.print();
</script>
</head>
<body>
<div class="print">fd</div>
<div class="print">fdfd</div>
</body>
</html>

Answer

giannis.epp picture giannis.epp · Oct 23, 2013

Have you tried this?

@media print {
    html, body {
        height: 99%;    
    }
}