page-orientation
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The page-orientation
CSS descriptor for the @page
at-rule controls the rotation of a printed page. It handles the flow of content across pages when the orientation of a page is changed. This behavior differs from the size
descriptor in that a user can define the direction in which to rotate the page.
This descriptor helps with the layout and orientation of printed documents, especially when documents are printed double-sided. A user can specify how the pages will be rotated when printed. This is particularly useful to lay out content such as tables, which may be wider than the rest of the content, in a different orientation.
Note: Margin boxes and other positional elements have no special interaction with this descriptor. Margins are laid out as normal in the unrotated page, then rotated along with everything else.
Syntax
/* Displays the print content in an upright position */
@page {
page-orientation: upright;
}
/* Displays the print content rotated counter-clockwise */
@page {
page-orientation: rotate-left;
}
/* Displays the print content rotated clockwise */
@page {
page-orientation: rotate-right;
}
Values
upright
-
No orientation is applied and the page is laid out and formatted as normal.
rotate-left
-
After a page is laid out, the page must be displayed rotated a quarter turn to the left (counter-clockwise).
rotate-right
-
After the page is laid out, the page must be displayed rotated a quarter turn to the right (clockwise).
Formal definition
Related at-rule | @page |
---|---|
Initial value | upright |
Computed value | as specified |
Formal syntax
Examples
Rotating printed pages
This example shows how the contents of a print document can be rotated to suit the page content and the page position.
CSS
In this first part of the CSS code, named pages are set up to define the direction in which to rotate the content.
@page upright {
size: portrait;
page-orientation: upright;
}
@page left {
size: landscape;
page-orientation: rotate-left;
}
@page right {
size: landscape;
page-orientation: rotate-right;
}
The following second part of the CSS code declares a named page rule defined above for the selectors, such as <section class="left">…</section>
.
@media print {
.upright {
page: upright;
}
.left {
page: left;
}
.right {
page: right;
}
}
Result
Click the print button to see the pages rotated.
Specifications
Specification |
---|
CSS Paged Media Module Level 3 # page-orientation-prop |
Browser compatibility
BCD tables only load in the browser