CSS @right-bottom At-Rule
The @right-bottom at-rule defines a page-margin box near the bottom of the right edge of a printed page.
It is nested inside @page and can display generated labels, page numbers, and other short content in paged media. Unlike ordinary CSS layout, page-margin boxes are visible in printed output or Print Preview rather than in the webpage itself.
Syntax
Place @right-bottom inside an @page rule. Its content declaration supplies the text or generated value displayed in the margin box.
@page {
margin: 20mm;
@right-bottom {
content: "Draft";
}
}
How @right-bottom Works
The right side of a page contains three distinct margin boxes: @right-top, @right-middle, and @right-bottom. The last of these occupies the lower portion of the right margin, outside the page content area.
Use margin-right in the enclosing @page rule to reserve room for the box. Content is generated independently on each printed page.
@page {
margin-right: 25mm;
@right-bottom {
content: "CONFIDENTIAL";
font-size: 9pt;
}
}
Short labels work best in a side margin. Long text can wrap or be clipped depending on the available margin space and the printing engine.
Related Page Margin Boxes
The three right-side margin boxes divide the right edge into top, middle, and bottom positions. They are different from @bottom-right, which belongs to the bottom edge of the page.
@page {
margin: 20mm;
@right-top {
content: "Report";
}
@right-middle {
content: "Review";
}
@right-bottom {
content: "2026";
}
}
Each box has its own declarations. You can use them together for a report title, review status, and year, provided the right page margin is wide enough for the content.
Page Counters
The built-in page counter identifies the current printed page. The pages counter can be used to show the total number of pages when the printing engine supports it.
@page {
margin: 20mm 25mm 20mm 20mm;
@right-bottom {
content: "Page " counter(page);
font-size: 9pt;
}
}
Using Page Selectors
Page pseudo-classes such as :left and :right allow different margin-box content on facing pages. These selectors describe the page position in a paged document, not the direction of text.
@page :right {
@right-bottom {
content: "Right-hand page";
}
}
@page :left {
@right-bottom {
content: none;
}
}
@right-bottom Example
This example prints a page number near the lower right side of each page. It requires a browser with support for CSS page-margin boxes.
@page {
size: A4;
margin: 20mm 25mm 20mm 20mm;
@right-bottom {
content: "Page " counter(page);
font: 9pt Arial, sans-serif;
color: #555;
}
}
@media print {
body {
color: #000;
}
}
Browser Result: This at-rule does not render a visible result in the normal webpage. To test it, place the CSS in a document stylesheet, add enough content to print several pages, then open the browser's Print Preview. Select A4 paper where available and check the right margin for the generated page number.
Browser Support
Support varies by browser version; Chromium 131 and later support page margin boxes. Test with Print Preview. Can I Use?
Page-margin boxes do not display in normal browser view. Verify alignment, clipping, and page numbering using print preview or a PDF export.
Specifications
The @right-bottom margin at-rule is defined by CSS Paged Media Module Level 3. The specification describes the sixteen page-margin boxes, their positions, and how their content is generated.
