CSS Portal

CSS page Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The page property assigns a named page context to elements in a paged-media formatting process, linking document content to the matching rules defined by the @page at-rule. When an element is associated with a specific page name, the page-level declarations (margins, margin boxes, size, and other page-scoped settings) defined in the corresponding @page rule are used for pages that contain that element. This makes page a bridge between block-level content in the document tree and the page-level formatting rules that control how that content is framed and decorated when reproduced in a paged medium like printed output or PDF.

Although page itself is about selecting which page template applies, its effect is felt through the page box and margin-box system: choosing a different page name can change outer and inner margins, headers/footers (margin boxes), and other page-specific adjustments that alter layout at the scale of whole pages. It does not directly describe low-level layout metrics inside the flow (line heights, text wrapping), but by changing the page context it can produce different paginated results for the same content. Because it operates at the paged-media layer, page is primarily relevant for elements that start or span page breaks or that you want to have presented within a particular page template.

When working with page, you typically consider it alongside properties that control fragmentation and page-boundary behavior. For controlling where page breaks are preferred or forced, the page-break-before property (and its related break-* equivalents) are commonly used; for preserving lines across page boundaries, properties like orphans and widows play an important role. In practice, use page when you need content to adopt a particular page template defined by @page rules, and combine it with break- and line-control properties to produce predictable, publication-quality paged output.

Definition

Initial value
auto
Applies to
Block level elements
Inherited
Yes
Computed value
Specified value
Animatable
No
JavaScript syntax
object.style.page

Syntax

page: auto | <identifier>

Values

  • auto
  • <identifier>

Example

<div class="document">
<header class="doc-header">
<h1>Sample Paginated Document</h1>
<p class="author">By Jane Doe</p>
</header>

<section class="cover">
<h2>Cover Page</h2>
<p>This is the cover page assigned to a specific @page rule.</p>
</section>

<section class="chapter">
<h2>Chapter 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam.</p>
</section>

<section class="chapter">
<h2>Chapter 2</h2>
<p>Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris.</p>
</section>
</div>
/* Page definitions */
@page cover {
  size: A4;
  margin: 4cm;
}

@page chapterPage {
  size: A4;
  margin: 2cm;
}

@page chapterPage:left {
  /* wider inner margin on left (verso) pages */
  margin-left: 3cm;
}

@page chapterPage:right {
  /* wider inner margin on right (recto) pages */
  margin-right: 3cm;
}

/* Assign pages to elements and control breaks */
.cover {
  page: cover;
  /* ensure the cover occupies its own page */
  break-after: page;
}

.chapter {
  page: chapterPage;
  break-after: page;
}

/* Basic on-screen styling */
body {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.4;
  color: #111;
  padding: 20px;
  background: #fff;
}

.document {
  max-width: 800px;
  margin: 0 auto;
}

.doc-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1, h2 {
  margin: 0 0 0.5rem 0;
}

.author {
  font-size: 0.9rem;
  color: #666;
}

Browser Support

The following information will show you the current browser support for the CSS page property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!