Search code examples
htmlcssprintingpage-break

HTML / CSS Page break not working


I have this page with multiple records I want to print.

The problem is that I get a blank page at the end.

My CSS:

.break { 
    page-break-after: always; 
    }

My html/php:

...
</table>
  <p class="break">&nbsp;</p>
    <?php } while ($row_RSacessorios = mysql_fetch_assoc($RSacessorios)); ?>
</body>
</html>
<?php
mysql_free_result($RSacessorios);
mysql_free_result($RSfases);
?>

Solution

  • I found a simple solution. I just remove the class "break" on the last record.

    if ($count < $total_rec) {
      <p class="break">&nbsp;</p>
    }