English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
When printing documents, the 'page' before the CSS property-break-The 'before' property is located before the element and before the page break. This property applies to elements that generate boxes.BlockElement. It does not apply to <p> elements that do not generate a blank box.
The following table provides usage descriptions and version histories of this property, as well as the syntax for using it in JavaScript scripts.
Default value: | auto |
---|---|
Applies to: | Block-level elements |
Inheritance: | None |
Animatable: | No.See also Animation properties. |
Version: | CSS 2,3 |
JavaScript Syntax: | object.style.pageBreakBefore="always" |
The syntax of this attribute is as follows:
page-break-before: auto | always | avoid | left | right | initial | inherit
The following example demonstrates how to use page-break-before attribute.
@media print { h1 { page-break-before: always; } }Test and see‹/›
The style rules in the above example set the pagination behavior to always at<h1>page breaks before the element, so that the element always appears at the top of a new page.
Note:the page-break-The before attribute is only applicable to the root element ortable-rowelements in the normal flow ofBlockElement.
The following table describes the values of this attribute.
Values | Description |
---|---|
auto | If necessary, insert a page break before the element. This is the default value. |
always | Always force a page break before the element. |
avoid | Avoid page breaks before the element. |
left | Force a page break once or twice before the element, so that the next page will become the left-hand page. |
right | Force a page break once or twice before the element, so that the next page will become the right-hand page. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts its parent element page-break-before Attribute Values. |
page-break-Browser Compatibility for before Attribute, the numbers in the table below represent the minimum version number of the browsers that support this attribute; all mainstream browsers partially support this attribute.
|
Warning: Internet Explorer 8And earlier versions do not support these values left and right; any value is interpreted as always. Firefox, Chrome, and Safari do not support the values avoid, left, or right.
Please refer to the following tutorials:CSS Media Types.
Related Attributes:page-break-after,page-break-inside.