css page-break-before attribute is used to add a page break before the specified element. Note that this attribute cannot be used on absolutely positioned elements, and should also be avoided in tables, floating elements, and block elements with borders. All browsers support the page-break-before attribute.
How to use the css page-break-before attribute?
The page-break-before property adds a page break before the specified element.
Note: Although you can use always to force page breaks, there is no guarantee that the insertion of page breaks will be avoided. The most the creator can do is ask the user agent to avoid inserting page breaks as much as possible. Applies to: non-floating block-level elements whose position value is relative or static.
Note: All major browsers support the page-break-before attribute. The property values "left", "right", and "inherit" are not supported in any version of Internet Explorer (including IE8). Firefox, Chrome, and Safari do not support the attribute values "avoid", "left", and "right".
css page-break-before attribute Example
Always insert a page break before the
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> @media print { h1 {page-break-before: always;} } </style> </head> <body> .... </body> </html>
The above is the detailed content of How to use css page-break-before attribute. For more information, please follow other related articles on the PHP Chinese website!