Preventing Additional Blank Pages When Printing with CSS
When printing HTML documents using a CSS property, users may encounter an issue where an extra blank page is printed before or after the intended content. To resolve this issue, consider the following solutions:
One approach is to use the page-break-after property with a value of always. However, this can introduce an extra blank page before the content. To avoid this, try setting page-break-before to always.
Alternatively, a more effective method is to utilize media queries specifically for printing purposes, such as:
@media print { html, body { height: 99%; } }
By setting the height of the HTML and body elements to 99% within the print media query, you can eliminate any additional blank space that may be causing the extra page to be printed.
The above is the detailed content of How to Prevent Extra Blank Pages When Printing with CSS?. For more information, please follow other related articles on the PHP Chinese website!