English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attributes大全

CSS page-break-Usage and examples of 'before' property

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"

page-break-Syntax of before usage

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.

Attribute Values

The following table describes the values of this attribute.

ValuesDescription
autoIf necessary, insert a page break before the element. This is the default value.
alwaysAlways force a page break before the element.
avoidAvoid page breaks before the element.
leftForce a page break once or twice before the element, so that the next page will become the left-hand page.
rightForce a page break once or twice before the element, so that the next page will become the right-hand page.
initialSet this attribute to its default value.
inheritIf specified, the associated element adopts its parent element page-break-before Attribute Values.

Browser Compatibility

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.

  • Firefox 1+

  • Google Chrome1+

  • Internet Explorer 4+

  • Apple Safari 1.2+

  • Opera 7+

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.

Read More

Please refer to the following tutorials:CSS Media Types.

Related Attributes:page-break-after,page-break-inside.