Marks on the page / Page border frame
A border or frame around every page of a certificate or diploma
A decorative rule or ornamental frame drawn around the whole page, used on certificates, awards and formal documents.
Why this block is harder than it looks
A page frame has to be positioned against the sheet rather than against the content, which rules out a border on the body element, because the body is as tall as its content and not as tall as the page. It also has to sit inside the printer's unprintable margin, which on a domestic device can be as much as 6mm and is not the same on all four edges. And it has to repeat, so a single bordered element is wrong for the same reason a single watermark is. The result is that the answer is a fixed-position box measured from the page edge, and every value in it is a physical measurement.
The decisions that make it work
Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.
- Draw it as a fixed-position element inset from the page edge in millimetres, not as a border on the body or on a wrapper.
- Keep it at least 8mm from the paper edge so it clears the unprintable margin on ordinary printers. A frame that is clipped on one edge looks worse than no frame.
- Set the page margins so the content sits inside the frame with a real gap. A frame touching the text reads as a mistake.
- Use strokes rather than background fills wherever possible, because strokes survive print settings that drop backgrounds.
- For an ornamental frame, use SVG with a stroke rather than a bitmap. It scales to the page and stays crisp at any output resolution.
- Check it on the second page. A frame that only appears on page one is the single most common outcome of building it in the flow.
The fragment
Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.
<div class="frame" aria-hidden="true"></div>
<style>
@page { size: A4; margin: 30mm; } /* content sits well inside the frame */
.frame {
position: fixed; /* per page, not per document */
top: 12mm; right: 12mm; bottom: 12mm; left: 12mm;
border: 1.5pt solid #1d1812;
pointer-events: none;
}
/* an inner hairline, the usual certificate treatment */
.frame::after {
content: "";
position: absolute;
inset: 2.5mm;
border: 0.5pt solid #1d1812;
}
</style>What breaks when it is built the obvious way
Putting the border on a wrapper with height: 100%. On a single-page document it looks right, and on a two-page one the frame is drawn once around the whole flow, so page one has three sides and page two has the fourth.
How to prove it survived pagination
Render two pages and confirm the frame is complete on both. Then print on a real printer and confirm all four edges are present, since the unprintable margin is frequently larger at the bottom than at the top and the bottom edge is the one that goes missing.
Where it sits in a finished document
This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The certificate template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.
Frequently asked
Will this fragment work on its own?
Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.
Why does it look right in a browser and wrong in the PDF?
Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.
Do I need a special option on the render request for this?
No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.
Other parts of a document
The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.
Leaving space for a physical stamp or seal on a printed document
A reserved clear area where a rubber stamp, an embossed seal or a wet signature will be applied after printing.
Bleed and crop marks on a document that will be trimmed
Extra artwork beyond the finished page edge and the short rules that show a trimmer where to cut, needed for anything printed oversize and cut down.
A photo grid with captions that keeps images the same size
A grid of photographs with numbered captions, used in surveys, inspections and incident reports where the images are the evidence.
A tax breakdown table with one row per rate that stays together
A small table showing taxable amount and tax for each distinct rate in the document, which exists because a single tax line stops being enough as soon as an invoice mixes rates.
Certificate, as a complete file
The whole document with this block already in place, ready to copy and change.
position: fixed in paged output
The property carrying the weight here, with its real support status.
Every part of a document
The full list, grouped by the kind of problem the block poses.
Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.